public class StateRunner extends Object implements Runnable, Initializable<Class<? extends State>>
org.openbase.jul.pattern.statemachine.State interface.
The state graph is defined by the states itself.
Whenever a state has finished its task the next state transition is defined by the state itself via the return value of the call method which defines the next state.
Start this state machine via the global executor service after initialization.
e.g. GlobalCachedExecutorService.submit(stateMaschineInstance)| Modifier and Type | Field and Description |
|---|---|
static String |
STATE_CHANGE |
static String |
STATE_ERROR |
| Constructor and Description |
|---|
StateRunner() |
| Modifier and Type | Method and Description |
|---|---|
void |
addPropertyChangeListener(PropertyChangeListener listener)
Method registers a property change listener which will be informed about state transitions.
|
State |
getCurrentState()
Method returns the state which is currently processed.
|
void |
init(Class<? extends State> stateClass)
Defines the initial state of the state machine.
|
boolean |
isCurrentState(Class clazz)
Method can be used to verify if the given state is currently processed.
|
void |
removePropertyChangeListener(PropertyChangeListener listener)
Method removes a previously registered property change listener.
|
void |
run()
Method starts the state machine.
|
public static final String STATE_CHANGE
public static final String STATE_ERROR
public void init(Class<? extends State> stateClass) throws InitializationException
init in interface Initializable<Class<? extends State>>stateClass - InitializationExceptionpublic void run()
public void addPropertyChangeListener(PropertyChangeListener listener)
listener - the change listener to register.public void removePropertyChangeListener(PropertyChangeListener listener)
listener - the change listener to remove.public State getCurrentState()
public boolean isCurrentState(Class clazz)
clazz - the class to define the state type.Copyright © 2015–2018 openbase.org. All rights reserved.