public final class StateHolder<E> extends Object
Modifier and Type | Class and Description |
---|---|
protected static class |
StateHolder.ConditionElement<E> |
Constructor and Description |
---|
StateHolder()
Constructs
StateHolder . |
StateHolder(E initialState)
Constructs
StateHolder . |
Modifier and Type | Method and Description |
---|---|
E |
getState()
Gets current state
Current StateHolder locking mode will be used
|
ReentrantReadWriteLock |
getStateLocker()
Gets Read/Write locker, which is used by this
StateHolder |
protected void |
notifyConditionListeners() |
Future<E> |
notifyWhenConditionMatchState(Condition condition,
CompletionHandler<E> completionHandler)
Register listener, which will be notified, when state will match the condition.
|
Future<E> |
notifyWhenStateIsEqual(E state,
CompletionHandler<E> completionHandler)
Register listener, which will be notified, when state will be equal to passed
one.
|
Future<E> |
notifyWhenStateIsNotEqual(E state,
CompletionHandler<E> completionHandler)
Register listener, which will be notified, when state will become not equal
to passed one.
|
void |
setState(E state)
Sets current state
Current StateHolder locking mode will be used
|
public StateHolder()
StateHolder
.public StateHolder(E initialState)
StateHolder
.public E getState()
public void setState(E state)
state
- public ReentrantReadWriteLock getStateLocker()
StateHolder
public Future<E> notifyWhenStateIsEqual(E state, CompletionHandler<E> completionHandler)
StateHolder
's listener set.state
- State, listener is interested incompletionHandler
- that will be notified. This StateHolder
implementation works with Runnable, Callable, CountDownLatch, Object
listenersConditionListener
, if current state is not equal to required
and listener was registered, null if current state is equal to required.
In both cases listener will be notifiedpublic Future<E> notifyWhenStateIsNotEqual(E state, CompletionHandler<E> completionHandler)
StateHolder
's listener set.state
- State, listener is interested incompletionHandler
- that will be notified. This StateHolder
implementation works with Runnable, Callable, CountDownLatch, Object
listenersConditionListener
, if current state is equal to required
and listener was registered, null if current state is not equal to required.
In both cases listener will be notifiedpublic Future<E> notifyWhenConditionMatchState(Condition condition, CompletionHandler<E> completionHandler)
StateHolder
's listener set.condition
- Condition, the listener is interested incompletionHandler
- that will be notified. This StateHolder
implementation works with Runnable, Callable, CountDownLatch, Object
listenersConditionListener
, if current state doesn't match the condition
and listener was registered, null if current state matches the condition.
In both cases listener will be notifiedprotected void notifyConditionListeners()
Copyright © 2015 Oracle Corporation. All rights reserved.