E - the type of the entity owning this state machineS - the type of the states of this state machinepublic interface StateMachine<E,S extends State<E>>
| Modifier and Type | Method and Description |
|---|---|
void |
changeState(S newState)
Performs a transition to the specified state.
|
S |
getCurrentState()
Returns the current state of this state machine.
|
S |
getGlobalState()
Returns the global state of this state machine.
|
S |
getPreviousState()
Returns the last state of this state machine.
|
boolean |
isInState(S state)
Indicates whether the state machine is in the given state.
|
boolean |
revertToPreviousState()
Changes the state back to the previous state.
|
void |
setGlobalState(S state)
Sets the global state of this state machine.
|
void |
setInitialState(S state)
Sets the initial state of this state machine.
|
void |
update()
Updates the state machine.
|
void update()
Implementation classes should invoke first the update method of the global state (if any) then the update
method of the current state.
void changeState(S newState)
newState - the state to transition toboolean revertToPreviousState()
true in case there was a previous state that we were able to revert to.
In case there is no previous state,
no state change occurs and false will be returned.void setInitialState(S state)
state - the initial state.void setGlobalState(S state)
state - the global state.S getCurrentState()
S getGlobalState()
Implementation classes should invoke the update method of the global state every time the FSM is updated. Also, they
should never invoke its enter and exit method.
S getPreviousState()
boolean isInState(S state)
state - the state to be compared with the current stateCopyright © 2018. All rights reserved.