Ability to decorate ChangeListener

Mario Ivankovits mario at datenwort.at
Sat Mar 22 05:57:14 UTC 2014


Hi!

In one of my ObservableValue implementations I do have the need to decorate ChangeListener added to it.
Today this is somewhat complicated to implement, as I have to keep a map of the original listener to the decorated one to being able to handle the removal process of a listener. Because the outside World did not know that I decorated the listener and the instance passed in to removeListener ist the undecorated one.

We can make things easier with a small change in ExpressionHelper.removeListener. When iterating through the listener list, the listener passed in as argument to removeListener is asked if it is equal to the one stored

                    if (listener.equals(changeListeners[index])) {

If we flip this to

		if (changeListeners[index].equals(listener)) {

a listener decoration can be smart enough to not only check against itself, but also against its delegate.

What do you think?

I could prepare a patch for the *ExpressionHelper classes.


Best regards,
Mario




More information about the openjfx-dev mailing list