Package net.apartium.cocoabeans.state
Class AttachedWatcher<T>
java.lang.Object
net.apartium.cocoabeans.state.Watcher<T>
net.apartium.cocoabeans.state.AttachedWatcher<T>
- Type Parameters:
T-
- All Implemented Interfaces:
Observer
Represents a watcher attached to an operator
- See Also:
-
Field Summary
-
Constructor Summary
ConstructorsConstructorDescriptionAttachedWatcher(Observable<T> depends, Consumer<T> consumer) Constructs a new instance. -
Method Summary
Modifier and TypeMethodDescriptionvoidattach(WatcherOperator manager) Attach this instance to an operator.voiddetach()Detaches this watcher instance from its associatedWatcherOperator.Returns theWatcherOperatorthis watcher instance is attached to.booleanChecks if this watcher instance is currently attached to aWatcherOperator.Methods inherited from class net.apartium.cocoabeans.state.Watcher
flagAsDirty, heartbeat
-
Constructor Details
-
AttachedWatcher
Constructs a new instance.- Parameters:
depends- theObservable<T>state that this watcher is observing.consumer- the action to perform when the observed state changes.
-
-
Method Details
-
attach
Attach this instance to an operator.- Parameters:
manager- operator to associate this instance to- Throws:
IllegalArgumentException- if this watcher is already attached
-
isAttached
public boolean isAttached()Checks if this watcher instance is currently attached to aWatcherOperator.- Returns:
trueif this watcher is attached to an operator,falseotherwise
-
getManager
Returns theWatcherOperatorthis watcher instance is attached to.- Returns:
- the operator managing this watcher, or
nullif not attached
-
detach
public void detach()Detaches this watcher instance from its associatedWatcherOperator. Once detached, the watcher will no longer be managed by the operator and will not trigger on state changes.- Overrides:
detachin classWatcher<T>- Throws:
IllegalArgumentException- if this watcher is not currently attached to an operator
-