public class AbstractStateMachine<S extends Enum> extends Object implements Stateful<S>
Stateful
implementation which acts like a simple state machine.
This class is thread safe, so state transitions can be issued from any thread without any further synchronization.Modifier | Constructor and Description |
---|---|
protected |
AbstractStateMachine(S initialState)
Creates a new state machine.
|
Modifier and Type | Method and Description |
---|---|
boolean |
hasSubscribers()
Returns true if there are subscribers observing the state stream.
|
boolean |
isState(S state)
Check if the given state is the same as the current one.
|
S |
state()
Returns the current state.
|
rx.Observable<S> |
states()
Returns a infinite observable which gets updated when the state of the component changes.
|
protected void |
transitionState(S newState)
Transition into a new state.
|
protected AbstractStateMachine(S initialState)
initialState
- the initial state of the state machine.public final rx.Observable<S> states()
Stateful
public final boolean isState(S state)
Stateful
public boolean hasSubscribers()
Stateful
hasSubscribers
in interface Stateful<S extends Enum>
protected void transitionState(S newState)
newState
- the states to transition into.Copyright © 2018 Couchbase, Inc.. All rights reserved.