public class TemplateBasedStateMachine<S,E,C> extends java.lang.Object implements StateMachine<S,E,C>
| Constructor and Description |
|---|
TemplateBasedStateMachine(TransitionModel<S,E,C> model,
S initial,
java.util.concurrent.locks.Lock lock) |
| Modifier and Type | Method and Description |
|---|---|
boolean |
fireEvent(E event)
Fires an event at the state machine, possibly triggering a state change
|
boolean |
fireEvent(E event,
C context)
Fires an event at the state machine, possibly triggering a state change
|
boolean |
forceSetState(S forcedState)
Forces the state machine to enter the forcedState even if there are no transitions leading to it
No transition actions are run but exit actions on the current state and entry actions on the new state are run
|
S |
getCurrentState()
Gets the current state of the machine
|
java.util.Map<E,java.util.Collection<? extends Transition<S,C>>> |
getPossibleTransitions(S fromState)
Returns all possible transitions from a given state grouped by the event that triggers the transition.
|
void |
rawSetState(S rawState)
Sets the state of the state machine to the rawState even if there are no transitions leading to it
No transition, entry or exit actions are run
|
public TemplateBasedStateMachine(TransitionModel<S,E,C> model, S initial, java.util.concurrent.locks.Lock lock)
public S getCurrentState()
StateMachinegetCurrentState in interface StateMachine<S,E,C>public boolean fireEvent(E event)
StateMachinefireEvent in interface StateMachine<S,E,C>event - the event that is firedpublic boolean fireEvent(E event, C context)
StateMachinefireEvent in interface StateMachine<S,E,C>event - the event that is firedcontext - the context to be sent to any actions that are run on a state change. Used to supply parameters to
actions and conditionspublic void rawSetState(S rawState)
StateMachinerawSetState in interface StateMachine<S,E,C>rawState - the state the machine will be in after this method is calledpublic boolean forceSetState(S forcedState)
StateMachineforceSetState in interface StateMachine<S,E,C>forcedState - the state the machine will be in after this method is calledpublic java.util.Map<E,java.util.Collection<? extends Transition<S,C>>> getPossibleTransitions(S fromState)
StateMachinegetPossibleTransitions in interface StateMachine<S,E,C>fromState - the state to retrieve the outgoing transitions from.