BindingHelper.
For unidirectional bindings a given target property will always have one and only helper at any time.
When a binding is not necessary anymore it's opportune to dispose it either with dispose() or
unbind(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 BindingBuilder.with(BiConsumer).
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 usesBindingBuilder.-
Method Summary
Modifier and TypeMethodDescription<T> BindingManagerapply(BindingBuilder<T> bindingBuilder, BindingHelper<T> bindingHelper) Creates a unidirectional binding with the given arguments.<T> BindingBuilder<T>Creates a newBindingBuilderwith the given target.<T> BindingBuilder<T>bind(ObservableValue<? extends T> target) Creates and returns a newBindingBuilderwith the given target.voiddispose()Unbinds every property stored in the manager and then clears the bindings map.static BindingManagerinstance()Retrieves the instance of the BindingManager.booleanisBound(ObservableValue target) Checks if the bindings map contains the given target.booleanisEmpty()Checks ifsize()is 0;booleanisIgnoreBinding(ObservableValue target) Checks if there's an existing binding for the given target and the associatedBindingHelper's ignoreBinding state.intsize()The number of bindings in the map.<T> BindingManagerunbind(ObservableValue<T> target) If the given target is in the map, removes it and callsBindingHelper.unbind().unbindReadOnly(ReadOnlyBooleanWrapper target) Retrieves the read-only property withReadOnlyBooleanWrapper.getReadOnlyProperty()and callsunbind(ObservableValue)on it.unbindReadOnly(ReadOnlyDoubleWrapper target) Retrieves the read-only property withReadOnlyDoubleWrapper.getReadOnlyProperty()and callsunbind(ObservableValue)on it.unbindReadOnly(ReadOnlyFloatWrapper target) Retrieves the read-only property withReadOnlyFloatWrapper.getReadOnlyProperty()and callsunbind(ObservableValue)on it.unbindReadOnly(ReadOnlyIntegerWrapper target) Retrieves the read-only property withReadOnlyIntegerWrapper.getReadOnlyProperty()and callsunbind(ObservableValue)on it.unbindReadOnly(ReadOnlyLongWrapper target) Retrieves the read-only property withReadOnlyLongWrapper.getReadOnlyProperty()and callsunbind(ObservableValue)on it.<T> BindingManagerunbindReadOnly(ReadOnlyObjectWrapper<T> target) Retrieves the read-only property withReadOnlyObjectWrapper.getReadOnlyProperty()and callsunbind(ObservableValue)on it.unbindReadOnly(ReadOnlyStringWrapper target) Retrieves the read-only property withReadOnlyStringWrapper.getReadOnlyProperty()and callsunbind(ObservableValue)on it.
-
Method Details
-
instance
Retrieves the instance of the BindingManager. -
bind
Creates and returns a newBindingBuilderwith the given target. -
bind
Creates a newBindingBuilderwith the given target.The difference with the above method is that it accepts a
Property, which means that it's not necessary to specify how to update the target, by default it usesWritableValue.setValue(Object). -
apply
Creates a unidirectional binding with the given arguments. TheBindingBuilderspecifies the target, the targetUpdater and the source.Calls
biBindingCheck(ObservableValue)on the target before proceeding.If the target is already bound,
unbind(ObservableValue)is called on the target before proceeding.At this point puts a new entry in the bindings map with the target and the specified
If usingBindingHelper. Then the actual bind happens by calling the binding helper methods.BindingBuilder.create()it's not necessary to call this method too!! -
unbind
If the given target is in the map, removes it and callsBindingHelper.unbind(). -
unbindReadOnly
Retrieves the read-only property withReadOnlyBooleanWrapper.getReadOnlyProperty()and callsunbind(ObservableValue)on it. -
unbindReadOnly
Retrieves the read-only property withReadOnlyStringWrapper.getReadOnlyProperty()and callsunbind(ObservableValue)on it. -
unbindReadOnly
Retrieves the read-only property withReadOnlyIntegerWrapper.getReadOnlyProperty()and callsunbind(ObservableValue)on it. -
unbindReadOnly
Retrieves the read-only property withReadOnlyLongWrapper.getReadOnlyProperty()and callsunbind(ObservableValue)on it. -
unbindReadOnly
Retrieves the read-only property withReadOnlyFloatWrapper.getReadOnlyProperty()and callsunbind(ObservableValue)on it. -
unbindReadOnly
Retrieves the read-only property withReadOnlyDoubleWrapper.getReadOnlyProperty()and callsunbind(ObservableValue)on it. -
unbindReadOnly
Retrieves the read-only property withReadOnlyObjectWrapper.getReadOnlyProperty()and callsunbind(ObservableValue)on it. -
dispose
public void dispose()Unbinds every property stored in the manager and then clears the bindings map. -
size
public int size()The number of bindings in the map. -
isEmpty
public boolean isEmpty()Checks ifsize()is 0; -
isIgnoreBinding
Checks if there's an existing binding for the given target and the associatedBindingHelper's ignoreBinding state. -
isBound
Checks if the bindings map contains the given target.
-