On 24.3.2014 15:24, Mario Ivankovits wrote:
But, after this discussion I do not see why one ever used .equals() at all.

Look, it does not fit my needs, I do not see any use-case where one would add 
an removeListener with asymmetric .equals() and thus it is better you use == I 
This clarifies that EXACTLY the added listener instance is required to remove 
any listener AND it gives no room to discussions like we had because the 
indention is perfectly clear - even to those reading JavaFX core code and bug 
fixing things in JavaFX.
For me this would be fine and understandable - I will go the 
decorator-cache-map so I will be fine always.

One example might be in bidirectional binding. There's a special listener that takes the 2 properties that are bound together and it's equals returns true if the other listener is of the same class and it's two properties (no matter in what order) are identical. This way, you can just write Bindings.unbindBidirectional() and the internal implementation does not need to remember the listener instance anywhere. The equals() is symmetric in this case, but == would not work here.


Reply via email to