On Mon, 24 May 2021 11:56:35 GMT, Jose Pereda <[email protected]> wrote:

> ListPropertyBase::bind, SetPropertyBase::bind, MapPropertyBase::bind have a 
> check on whether a different instance of the observable is the same, and this 
> PR changes that to check against identity.
> 
> Tests are included.

Having a look at the `equals` implementation in ReadOnly{List/Set/Map}Property, 
it is oriented to check the contents of the collection. For the List case, for 
instance, `List::equals` javadoc clearly states that 

> two lists are defined to be equal if they contain the same elements in the 
> same order

While this makes sense in many cases, it doesn't for _binding_ a 
{List/Set/Map}PropertyBase, as we don't bind each collection's items one by 
one, but the collections themselves.

In this case, calling:

c.bind(a);
c.bind(b);

over two different collections, even if they have the exact same content, would 
necessary imply a change of observables, and the need to unbind first the old 
binding and update the observable/listener accordingly. If later on `b` is 
modified, but not `a`, it would be expected that `c` will react to those 
changes. However, that is not happening as `equals` is currently preventing it.

So I can't see a possible use case for this.

-------------

PR: https://git.openjdk.java.net/jfx/pull/516

Reply via email to