Attach ChangeListener to multiple properties

Viewed 1515

I do have a model which consists of multiple observable SimpleDoubleProperty, i now have a program which runs a function depending on changes on the observable properties.

I now do have a function calculateThings which gets called on changes:

public double calculateThings() {
  return getA() + getB() + getC();
}

For triggering that function i do attach a ChangeListener to every Property:

aProperty().addListener(observable -> calculateThings());
bProperty().addListener(observable -> calculateThings());
cProperty().addListener(observable -> calculateThings());

Is there a possiblity to add a ChangeListener to multiple properties in order to simplify the change listening? The Bindings API is not suitable here, the calculations are rather complex.

Like:

commonObservable().addListener(observable -> calculateThings());
1 Answers
Related