State
- An enum of states to usepublic class StateMachine<State extends java.lang.Enum<State>>
extends java.lang.Object
Constructor and Description |
---|
StateMachine(State startState,
com.google.common.collect.Multimap<State,State> transitions) |
Modifier and Type | Method and Description |
---|---|
void |
checkState(State... requiredStates)
Checks that the machine is in one of the given states.
|
void |
checkState(State requiredState)
Checks that the machine is in the given state.
|
State |
getState() |
java.lang.String |
toString() |
void |
transition(State newState)
Transitions to a new state, provided that the required transition exists
|
public void checkState(State requiredState) throws java.lang.IllegalStateException
requiredState
- java.lang.IllegalStateException
public void checkState(State... requiredStates) throws java.lang.IllegalStateException
requiredStates
- java.lang.IllegalStateException
public void transition(State newState) throws java.lang.IllegalStateException
newState
- java.lang.IllegalStateException
- If no state transition exists from oldState to newStatepublic State getState()
public java.lang.String toString()
toString
in class java.lang.Object