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>> extends Telegraph
| 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 |
handleMessage(Telegram telegram)
Handles received telegrams.
|
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 stateboolean handleMessage(Telegram telegram)
Implementation classes should first route the telegram to the current state. If the current state does not deal with the message, it should be routed to the global state.
handleMessage in interface Telegraphtelegram - the received telegramCopyright © 2017. All rights reserved.