public class StateMachine
extends java.lang.Object
implements java.lang.Cloneable
| Modifier and Type | Field and Description |
|---|---|
private State |
currentState
The current state of the state machine
|
private java.lang.String |
description
A description of the state machine
|
private static org.jboss.logging.Logger |
log |
private State |
startState
The starting state
|
private java.util.HashSet |
states
The set of states making up the state machine
|
| Constructor and Description |
|---|
StateMachine(java.util.Set states,
State startState)
Create a state machine given its states and start state.
|
StateMachine(java.util.Set states,
State startState,
java.lang.String description)
Create a state machine given its states and start state.
|
| Modifier and Type | Method and Description |
|---|---|
java.lang.Object |
clone()
Make a copy of the StateMachine maintaining the current state.
|
State |
getCurrentState()
Get the current state of the state machine.
|
java.lang.String |
getDescription()
Get the state machine description.
|
State |
getStartState()
Get the start state of the state machine.
|
java.util.Set |
getStates()
Get the states of the state machine.
|
State |
nextState(java.lang.String actionName)
Transition to the next state given the name of a valid transition.
|
State |
reset()
Reset the state machine back to the start state
|
java.lang.String |
toString() |
private static org.jboss.logging.Logger log
private java.lang.String description
private java.util.HashSet states
private State startState
private State currentState
public StateMachine(java.util.Set states,
State startState)
states - - SetstartState - - the starting statepublic StateMachine(java.util.Set states,
State startState,
java.lang.String description)
states - - SetstartState - - the starting statedescription - - an optional description of the state machinepublic java.lang.Object clone()
clone in class java.lang.Objectpublic java.lang.String getDescription()
public State getCurrentState()
public State getStartState()
public java.util.Set getStates()
public State nextState(java.lang.String actionName) throws IllegalTransitionException
actionName - - the name of transition that is valid for the
current state.IllegalTransitionExceptionpublic State reset()
public java.lang.String toString()
toString in class java.lang.Object