T
- the type the observed ObservableValue
's wrapspublic class ExecuteAlwaysWhen<T> extends Object
ObservableValue
's value fulfills a certain condition.
The action will not be executed before executeWhen()
is called. The action is executed every time the value
passes the condition. If this can happen in parallel in several threads, the action must be thread-safe as no further
synchronization is provided by this class. Further execution can be prevented by calling cancel()
.
This class guarantees that regardless of the way different threads interact with the ObservableValue
the
action will be executed...
executeWhen()
if either the observable's initial value or one it was changed to passes
the condition
executeWhen()
returns
executeWhen()
, this class does not guarantee that
the first value to pass the condition is the one handed to the action. Depending on the interaction of those threads
it might be the initial value or one of several which were set by those threads.
Use ExecuteWhen
to build an instance of this class.
Modifier and Type | Method and Description |
---|---|
void |
cancel()
Cancels the future execution of the action.
|
void |
executeWhen()
Executes the action (every time) when the observable's value passes the condition.
|
public void executeWhen() throws IllegalStateException
This is a one way function that must only be called once. Calling it again throws an
IllegalStateException
.
Call cancel()
to prevent further execution.
IllegalStateException
- if this method is called more than oncepublic void cancel()
executeWhen()
was not yet called or the action was
already executed, this is a no-op.This documentation is licensed under CC-BY 4.0, attributed to Nicolai Parlog from CodeFX.