T
- the type the ObservableValue
which will be observed by the constructed instance wrapspublic class ExecuteWhen<T> extends Object
Builder for ExecuteAlwaysWhen
and ExecuteOnceWhen
.
ObservableValue<State> workerState; ExecuteWhen.on(workerState) .when(state -> state == State.SUCCEEDED) .thenOnce(state -> logSuccess()) .executeWhen();
Modifier and Type | Method and Description |
---|---|
static <T> ExecuteWhen<T> |
on(javafx.beans.value.ObservableValue<T> observable)
Creates a new builder.
|
ExecuteAlwaysWhen<T> |
thenAlways(Consumer<? super T> action)
Creates an instance which:
observes the
ObservableValue (specified for this builder's construction) for new values
checks each new value against the condition set with when(Predicate) (calling which is required)
executes the specified action every time a value fulfills the condition
Note that the observation does not start until ExecuteAlwaysWhen.executeWhen() is called. |
ExecuteOnceWhen<T> |
thenOnce(Consumer<? super T> action)
Creates an instance which:
observes the
ObservableValue (specified for this builder's construction) for new values
checks each new value against the condition set with when(Predicate) (calling which is required)
executes the specified action once if a value fulfills the condition
Note that the observation does not start until ExecuteOnceWhen.executeWhen() is called. |
ExecuteWhen<T> |
when(Predicate<? super T> condition)
Specifies the condition the observable's value must fulfill in order for the action to be executed.
|
public static <T> ExecuteWhen<T> on(javafx.beans.value.ObservableValue<T> observable)
Execute...When
will observe the specified observable.T
- the type the ObservableValue
which will be observed by the constructed instance wrapsobservable
- the ObservableValue
which will be observed by the created Execute...When
instancespublic ExecuteWhen<T> when(Predicate<? super T> condition)
condition
- the condition as a Predicate
public ExecuteOnceWhen<T> thenOnce(Consumer<? super T> action) throws IllegalStateException
ObservableValue
(specified for this builder's construction) for new values
when(Predicate)
(calling which is required)
action
once if a value fulfills the condition
ExecuteOnceWhen.executeWhen()
is called. See
ExecuteOnceWhen
for details.action
- the Consumer
of the value which passed the conditionExecuteOnceWhen
IllegalStateException
- if when(Predicate)
was not calledpublic ExecuteAlwaysWhen<T> thenAlways(Consumer<? super T> action) throws IllegalStateException
ObservableValue
(specified for this builder's construction) for new values
when(Predicate)
(calling which is required)
action
every time a value fulfills the condition
ExecuteAlwaysWhen.executeWhen()
is called. See
ExecuteAlwaysWhen
for details.action
- the Consumer
of the value which passed the conditionExecuteOnceWhen
IllegalStateException
- if when(Predicate)
was not calledThis documentation is licensed under CC-BY 4.0, attributed to Nicolai Parlog from CodeFX.