public class StateMachine
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
protected State |
currentState |
protected java.util.ArrayList<Event> |
maskList |
protected java.util.HashMap<State,java.util.ArrayList<StateTransition>> |
stateGraph |
Constructor and Description |
---|
StateMachine() |
Modifier and Type | Method and Description |
---|---|
void |
addTransition(StateTransition transition)
addTransition
Adds a transition to the state machine.
|
State |
consumeEvent(Event event)
consumeEvent
Executes a state transition and returns the new state.
|
void |
maskEvent(Event event) |
protected void |
start(State state)
start
Define the start state of the state machine.
|
java.lang.String |
toString() |
protected State |
transition(Event event) |
void |
unMaskEvent(Event event) |
protected State currentState
protected java.util.HashMap<State,java.util.ArrayList<StateTransition>> stateGraph
protected java.util.ArrayList<Event> maskList
protected void start(State state)
state
- The initial state.public void addTransition(StateTransition transition)
transition
- the transition to add.public State consumeEvent(Event event)
event
- The event to consumepublic void maskEvent(Event event)
public void unMaskEvent(Event event)
public java.lang.String toString()
toString
in class java.lang.Object