Class When

java.lang.Object
com.tobiasdiez.easybind.When

public final class When extends Object
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 Type
    Method
    Description
    bind(javafx.beans.property.Property<T> target, javafx.beans.value.ObservableValue<? extends T> source)
    Sets up automatic binding and unbinding of target to/from source, based on the changing value of the encapsulated condition.
    bindContent(List<? super T> target, javafx.collections.ObservableList<? extends T> source)
    Sets up automatic binding and unbinding of target's items to/from source's items, based on the changing value of the encapsulated condition.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 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 of target to/from source, based on the changing value of the encapsulated condition. In other words, whenever the encapsulated condition is true, target is bound to source. Whenever the encapsulated condition is false, target is unbound. This keeps happening until unsubscribe() is called on the returned subscription. Unsubscribing the returned subscription may be skipped safely only when the lifetimes of all the encapsulated condition, source and target are the same.
      Parameters:
      target - target of the conditional binding
      source - 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, unbind target from source.
    • bindContent

      public <T> Subscription bindContent(List<? super T> target, javafx.collections.ObservableList<? extends T> source)
      Sets up automatic binding and unbinding of target's items to/from source's items, based on the changing value of the encapsulated condition. In other words, whenever the encapsulated condition is true, target's content is synced with source. Whenever the encapsulated condition is false, the sync is interrupted. This keeps happening until unsubscribe() is called on the returned subscription. Unsubscribing the returned subscription may be skipped safely only when the lifetimes of all the encapsulated condition, source and target are the same.
      Parameters:
      target - target of the conditional binding
      source - 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 synchronization target's content with source's content.