-
Nested Class Summary
Nested Classes -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic <T> SubscriptionbindConditionally(javafx.beans.property.Property<T> target, javafx.beans.value.ObservableValue<? extends T> source, javafx.beans.value.ObservableValue<Boolean> condition) Deprecated.Since 1.0.2.static <T> SubscriptionbindContent(List<? super T> target, javafx.collections.ObservableList<? extends T> source) Synchronizes the content of thetargetlist with thesourcelist.static <A,B, R> EasyBinding<R> combine(javafx.beans.value.ObservableValue<A> src1, javafx.beans.value.ObservableValue<B> src2, BiFunction<A, B, R> f) static <A,B, C, R> EasyBinding<R> combine(javafx.beans.value.ObservableValue<A> src1, javafx.beans.value.ObservableValue<B> src2, javafx.beans.value.ObservableValue<C> src3, EasyBind.TriFunction<A, B, C, R> f) static <A,B, C, D, R>
EasyBinding<R>combine(javafx.beans.value.ObservableValue<A> src1, javafx.beans.value.ObservableValue<B> src2, javafx.beans.value.ObservableValue<C> src3, javafx.beans.value.ObservableValue<D> src4, EasyBind.TetraFunction<A, B, C, D, R> f) static <A,B, C, D, E, R>
EasyBinding<R>combine(javafx.beans.value.ObservableValue<A> src1, javafx.beans.value.ObservableValue<B> src2, javafx.beans.value.ObservableValue<C> src3, javafx.beans.value.ObservableValue<D> src4, javafx.beans.value.ObservableValue<E> src5, EasyBind.PentaFunction<A, B, C, D, E, R> f) static <A,B, C, D, E, F, R>
EasyBinding<R>combine(javafx.beans.value.ObservableValue<A> src1, javafx.beans.value.ObservableValue<B> src2, javafx.beans.value.ObservableValue<C> src3, javafx.beans.value.ObservableValue<D> src4, javafx.beans.value.ObservableValue<E> src5, javafx.beans.value.ObservableValue<F> src6, EasyBind.HexaFunction<A, B, C, D, E, F, R> f) static <T,R> EasyBinding<R> combine(javafx.collections.ObservableList<? extends javafx.beans.value.ObservableValue<? extends T>> list, Function<? super Stream<T>, ? extends R> f) static <T> EasyObservableList<T>concat(javafx.collections.ObservableList<? extends T>... sources) static <T> EasyObservableList<T>flatten(javafx.collections.ObservableList<javafx.collections.ObservableList<? extends T>> sources) static <T> SubscriptionincludeWhen(Collection<T> collection, T element, javafx.beans.value.ObservableValue<Boolean> condition) Addselementtocollectionwhenconditionistrueand removes it fromcollectionwhenconditionisfalse.static <T> Subscriptionlisten(javafx.beans.value.ObservableValue<T> observable, javafx.beans.InvalidationListener listener) Adds an invalidation listener and returns a Subscription that can be used to remove that listener.static <T> Subscriptionlisten(javafx.beans.value.ObservableValue<T> observable, javafx.beans.value.ChangeListener<? super T> listener) Adds a change listener and returns a Subscription that can be used to remove that listener.static <T,U> EasyBinding<U> Returns an observable consisting of the result of applying the given function to the given observable value.static <T,U> EasyObservableList<U> static <A,B> EasyObservableList<B> Creates a new list in which each element is converted using the provided mapping.static <A,B> EasyObservableList<B> Similar tomapBacked(ObservableList, Function), but allows specifying if new objects should be created on update.static <T,O, R extends javafx.beans.value.ObservableValue<O>>
EasyBinding<O>mapObservable(javafx.beans.value.ObservableValue<T> source, Function<? super T, R> mapper) Returns an observable that, when the given observable value holds valuex, holds the value held by the observablef(x).static <T,R> EasyBinding<R> reduce(javafx.collections.ObservableList<? extends T> list, Function<? super Stream<? extends T>, ? extends R> accumulator) Creates a new binding that performs a reduction on the elements of this list, using the provided accumulation function.static <T> SelectBuilder<T>select(javafx.beans.value.ObservableValue<T> selectionRoot) Starts a selection chain.static <T,U> PropertyBinding<U> selectProperty(javafx.beans.value.ObservableValue<T> source, Function<? super T, ? extends javafx.beans.property.Property<U>> mapper) Similar tomapObservable(ObservableValue, Function), except the returned binding is also a property.static <T> SubscriptionInvokessubscriberfor the current and every new value ofobservable.static <E> OptionalBinding<E>valueAt(javafx.collections.ObservableList<E> list, int index) Creates a newOptionalBindingthat contains the element of anObservableListat the specified position.static <K,V> OptionalBinding<V> valueAt(javafx.collections.ObservableMap<K, V> map, K key) Creates a newOptionalBindingthat contains the mapping of a specific key in anObservableMap.static WhenEntry point for creating conditional bindings.static <T> EasyObservableValue<T>wrap(javafx.beans.value.ObservableValue<T> value) Creates a wrapper around the given observable to provide access to convenient helper methods (for fluent style)static <E> EasyObservableList<E>wrapList(javafx.collections.ObservableList<E> list) Creates a wrapper around the given observable list to provide access to convenient helper methods (for fluent style)static <T> ObservableOptionalValue<T>wrapNullable(javafx.beans.value.ObservableValue<T> value) Creates a wrapper around the given observable value that provides functionality similar to anOptional.
-
Constructor Details
-
EasyBind
public EasyBind()
-
-
Method Details
-
wrap
Creates a wrapper around the given observable to provide access to convenient helper methods (for fluent style)- Parameters:
value- the observable to wrap- Returns:
- a thin wrapper around the given observable
-
wrapNullable
public static <T> ObservableOptionalValue<T> wrapNullable(javafx.beans.value.ObservableValue<T> value) Creates a wrapper around the given observable value that provides functionality similar to anOptional.- Parameters:
value- the observable to wrap- Returns:
- a thin wrapper around the given observable
-
wrapList
Creates a wrapper around the given observable list to provide access to convenient helper methods (for fluent style)- Parameters:
list- the observable list to wrap- Returns:
- a thin wrapper around the given observable list
-
map
public static <T,U> EasyBinding<U> map(javafx.beans.value.ObservableValue<T> source, Function<? super T, ? extends U> mapper) Returns an observable consisting of the result of applying the given function to the given observable value.The value passed to the
mappermay benull. If this is not desired, usewrapNullable(source).map(mapper)instead.- Parameters:
source- the original observable value serving as inputmapper- the function to apply- Returns:
- the new observable value
- See Also:
-
mapObservable
public static <T,O, EasyBinding<O> mapObservableR extends javafx.beans.value.ObservableValue<O>> (javafx.beans.value.ObservableValue<T> source, Function<? super T, R> mapper) Returns an observable that, when the given observable value holds valuex, holds the value held by the observablef(x).Note that the
mapperis also invoked ifxisnull. A betternull-handling is possible withObservableOptionalValue.mapObservable(Function))}.- Parameters:
source- the original observable value serving as inputmapper- the function to apply, returning an observable value- See Also:
-
selectProperty
public static <T,U> PropertyBinding<U> selectProperty(javafx.beans.value.ObservableValue<T> source, Function<? super T, ? extends javafx.beans.property.Property<U>> mapper) Similar tomapObservable(ObservableValue, Function), except the returned binding is also a property. This means you can callsetValue()andbind()methods on the returned property, which delegates to the currently selected property.As the value of the
sourcechanges, so does the currently selected property. When the property returned from this method is bound, as the selected property changes, the previously selected property is unbound and the newly selected property is bound.Note that if the currently selected property is
null, then callinggetValue()on the returned value will returnnullregardless of any prior call tosetValue()orbind().Note that the
mapperis also invoked ifsourceholds anullvalue. A betternull-handling is possible withObservableOptionalValue.selectProperty(Function))}.Note that you need to retain a reference to the returned value to prevent it from being garbage collected.
-
map
public static <T,U> EasyObservableList<U> map(javafx.collections.ObservableList<? extends T> sourceList, Function<? super T, ? extends U> f) -
flatten
public static <T> EasyObservableList<T> flatten(javafx.collections.ObservableList<javafx.collections.ObservableList<? extends T>> sources) -
concat
@SafeVarargs public static <T> EasyObservableList<T> concat(javafx.collections.ObservableList<? extends T>... sources) -
mapBacked
public static <A,B> EasyObservableList<B> mapBacked(javafx.collections.ObservableList<A> source, Function<A, B> mapper) Creates a new list in which each element is converted using the provided mapping. All changes to the underlying list are propagated to the converted list.If the change event indicates that an item was updated, as determined by
ListChangeListener.Change.wasUpdated(), the mapping function is called to create a new object reflecting the updated value.In contrast to
map(ObservableList, Function), the items are converted when they are inserted instead of when they are accessed. Thus, the initial CPU overhead and memory consumption is higher but the access to list items is quicker. -
mapBacked
public static <A,B> EasyObservableList<B> mapBacked(javafx.collections.ObservableList<A> source, Function<A, B> mapper, boolean mapOnUpdate) Similar tomapBacked(ObservableList, Function), but allows specifying if new objects should be created on update.If
mapOnUpdateistrue, new objects are created when items in the source list are updated.If
mapOnUpdateisfalse, updates do not create new objects. This can be useful in scenarios where the mapped objects already have bindings or listeners that reflect changes from the source objects. -
combine
public static <A,B, EasyBinding<R> combineR> (javafx.beans.value.ObservableValue<A> src1, javafx.beans.value.ObservableValue<B> src2, BiFunction<A, B, R> f) -
combine
public static <A,B, EasyBinding<R> combineC, R> (javafx.beans.value.ObservableValue<A> src1, javafx.beans.value.ObservableValue<B> src2, javafx.beans.value.ObservableValue<C> src3, EasyBind.TriFunction<A, B, C, R> f) -
combine
public static <A,B, EasyBinding<R> combineC, D, R> (javafx.beans.value.ObservableValue<A> src1, javafx.beans.value.ObservableValue<B> src2, javafx.beans.value.ObservableValue<C> src3, javafx.beans.value.ObservableValue<D> src4, EasyBind.TetraFunction<A, B, C, D, R> f) -
combine
public static <A,B, EasyBinding<R> combineC, D, E, R> (javafx.beans.value.ObservableValue<A> src1, javafx.beans.value.ObservableValue<B> src2, javafx.beans.value.ObservableValue<C> src3, javafx.beans.value.ObservableValue<D> src4, javafx.beans.value.ObservableValue<E> src5, EasyBind.PentaFunction<A, B, C, D, E, R> f) -
combine
public static <A,B, EasyBinding<R> combineC, D, E, F, R> (javafx.beans.value.ObservableValue<A> src1, javafx.beans.value.ObservableValue<B> src2, javafx.beans.value.ObservableValue<C> src3, javafx.beans.value.ObservableValue<D> src4, javafx.beans.value.ObservableValue<E> src5, javafx.beans.value.ObservableValue<F> src6, EasyBind.HexaFunction<A, B, C, D, E, F, R> f) -
combine
public static <T,R> EasyBinding<R> combine(javafx.collections.ObservableList<? extends javafx.beans.value.ObservableValue<? extends T>> list, Function<? super Stream<T>, ? extends R> f) -
reduce
public static <T,R> EasyBinding<R> reduce(javafx.collections.ObservableList<? extends T> list, Function<? super Stream<? extends T>, ? extends R> accumulator) Creates a new binding that performs a reduction on the elements of this list, using the provided accumulation function.- Parameters:
list- the source listaccumulator- the accumulation function to apply- See Also:
-
select
Starts a selection chain. A selection chain is just a more efficient equivalent to a chain of flatMaps. -
bindConditionally
@Deprecated public static <T> Subscription bindConditionally(javafx.beans.property.Property<T> target, javafx.beans.value.ObservableValue<? extends T> source, javafx.beans.value.ObservableValue<Boolean> condition) Deprecated.Since 1.0.2. Usewhen(condition).bind(target, source)instead.Sets up automatic binding and unbinding oftargetto/fromsource, based on the changing value ofcondition. In other words, this method starts watchingconditionfor changes. Whenconditionchanges totrue,targetis bound tosource. Whenconditionchanges tofalse,targetis unbound. This keeps happening until eitherunsubscribe()is called on the returned subscription, ortargetis garbage collected.- Parameters:
target- target of the conditional bindingsource- source of the conditional bindingcondition- controls when to bind and unbind target to/from source- Returns:
- a subscription that can be used to dispose the conditional
binding set up by this method, i.e. stop observing
conditionand unbindtargetfromsource.
-
bindContent
public static <T> Subscription bindContent(List<? super T> target, javafx.collections.ObservableList<? extends T> source) Synchronizes the content of thetargetlist with thesourcelist.Calling this method ensures that the
targetcontains the same elements as thesource. If the content of thetargetchanges, thesourcewill be updated automatically.Once
sourceis bound to anObservableList, it must not be changed directly anymore.The binding can be removed by calling
Subscription.unsubscribe()on the returned subscription. This is the only difference toBindings.bindContent(List, ObservableList).- Type Parameters:
T- the type of thesourceelements- Parameters:
target- the target listsource- the source list- Returns:
- a subscription that can be used to stop syncing the lists.
-
when
Entry point for creating conditional bindings. -
includeWhen
public static <T> Subscription includeWhen(Collection<T> collection, T element, javafx.beans.value.ObservableValue<Boolean> condition) Addselementtocollectionwhenconditionistrueand removes it fromcollectionwhenconditionisfalse.- Returns:
- a subscription that can be used to stop observing
conditionand manipulatingcollection.
-
subscribe
public static <T> Subscription subscribe(javafx.beans.value.ObservableValue<T> observable, Consumer<? super T> subscriber) Invokessubscriberfor the current and every new value ofobservable.- Parameters:
observable- observable value to subscribe tosubscriber- action to invoke for values ofobservable.- Returns:
- a subscription that can be used to stop invoking subscriber
for any further
observablechanges.
-
listen
public static <T> Subscription listen(javafx.beans.value.ObservableValue<T> observable, javafx.beans.InvalidationListener listener) Adds an invalidation listener and returns a Subscription that can be used to remove that listener.Subscription s = observable.listen(obs -> doSomething()); // later s.unsubscribe();is equivalent to
InvalidationListener l = obs -> doSomething(); observable.addListener(l); // later observable.removeListener(); -
listen
public static <T> Subscription listen(javafx.beans.value.ObservableValue<T> observable, javafx.beans.value.ChangeListener<? super T> listener) Adds a change listener and returns a Subscription that can be used to remove that listener. See the example atlisten(ObservableValue, InvalidationListener). -
valueAt
Creates a newOptionalBindingthat contains the element of anObservableListat the specified position. The binding will be empty if theindexpoints behind theObservableListor to anullelement.- Parameters:
list- theObservableListindex- the position in theList- Returns:
- the new
OptionalBinding - Throws:
NullPointerException- if theObservableListisnullIllegalArgumentException- if (@code index < 0)
-
valueAt
Creates a newOptionalBindingthat contains the mapping of a specific key in anObservableMap. The binding will be empty if thekeyis not contained in the map or points to anullelement.- Parameters:
map- theObservableMapkey- the key in theMap- Returns:
- the new
ObjectBinding - Throws:
NullPointerException- if theObservableMapisnull
-