java.lang.Object
com.tobiasdiez.easybind.When
Starting point for creation of conditional bindings. Encapsulates a boolean
condition and provides fluent API to create conditional bindings based on
that condition.
-
Method Summary
Modifier and TypeMethodDescription<T> Subscriptionbind(javafx.beans.property.Property<T> target, javafx.beans.value.ObservableValue<? extends T> source) Sets up automatic binding and unbinding oftargetto/fromsource, based on the changing value of the encapsulated condition.<T> SubscriptionbindContent(List<? super T> target, javafx.collections.ObservableList<? extends T> source) Sets up automatic binding and unbinding oftarget's items to/fromsource's items, based on the changing value of the encapsulated condition.
-
Method Details
-
bind
public <T> Subscription bind(javafx.beans.property.Property<T> target, javafx.beans.value.ObservableValue<? extends T> source) Sets up automatic binding and unbinding oftargetto/fromsource, based on the changing value of the encapsulated condition. In other words, whenever the encapsulated condition istrue,targetis bound tosource. Whenever the encapsulated condition isfalse,targetis unbound. This keeps happening untilunsubscribe()is called on the returned subscription. Unsubscribing the returned subscription may be skipped safely only when the lifetimes of all the encapsulated condition,sourceandtargetare the same.- Parameters:
target- target of the conditional bindingsource- source of the conditional binding- Returns:
- a subscription that can be used to dispose the conditional
binding set up by this method, i.e. to stop observing the encapsulated
condition and, if the last observed value of the encapsulated condition
was
true, unbindtargetfromsource.
-
bindContent
public <T> Subscription bindContent(List<? super T> target, javafx.collections.ObservableList<? extends T> source) Sets up automatic binding and unbinding oftarget's items to/fromsource's items, based on the changing value of the encapsulated condition. In other words, whenever the encapsulated condition istrue,target's content is synced withsource. Whenever the encapsulated condition isfalse, the sync is interrupted. This keeps happening untilunsubscribe()is called on the returned subscription. Unsubscribing the returned subscription may be skipped safely only when the lifetimes of all the encapsulated condition,sourceandtargetare the same.- Parameters:
target- target of the conditional bindingsource- source of the conditional binding- Returns:
- a subscription that can be used to dispose the conditional
binding set up by this method, i.e. to stop observing the encapsulated
condition and, if the last observed value of the encapsulated condition
was
true, stop the synchronizationtarget's content withsource's content.
-