Module MaterialFX

Class BiBindingManager

java.lang.Object
io.github.palexdev.materialfx.bindings.BiBindingManager

public class BiBindingManager extends Object
This singleton class manages bidirectional bindings.

All bindings are stored in a map which associates the target property to a BiBindingHelper. For bidirectional bindings a given target property will always have one and only helper at any time. The sources list is managed by that manager, when a new bind is made on the same target, a new BiBindingHelper is created, which is the combination of the old one and the new one, BiBindingHelper.newFor(BiBindingHelper, BiBindingHelper, boolean) is used.

When a binding is not necessary anymore it's opportune to dispose it either with dispose() or unbind(ObservableValue, ObservableValue) or clear(ObservableValue).

This mechanism is so flexible that it also allows to bind read-only properties on the sole condition that you must have a way to set that property and it must be specified with BiBindingBuilder.

For these properties be careful during the unbind as in JavaFX the getReadOnlyProperty() method returns a completely different instance. For this reason the manager also offers unbind methods to unbind read-only wrappers.

To make the bindings building more readable it uses BiBindingBuilder.