S - the type of state of the FiniteStateMachine
public interface FiniteStateMachine<S extends Enum<S>>
FiniteStateMachine implements a general purpose finite-state-machine.Model, Transition, TransitionAction, StateEntryAction| Modifier and Type | Method and Description |
|---|---|
void |
addListener(FiniteStateMachineListener<S> listener)
Add a
FiniteStateMachineListener to the FiniteStateMachine. |
String |
getName()
Obtains the name of the
FiniteStateMachine. |
S |
getState()
Obtains the current state of the
FiniteStateMachine. |
long |
getTransitionCount()
Obtains the number of transitions that have occurred in the
FiniteStateMachine. |
void |
process(Event<S> event)
Request the
FiniteStateMachine to process the specified Event. |
void |
removeListener(FiniteStateMachineListener<S> listener)
Remove a
FiniteStateMachineListener from the FiniteStateMachine. |
boolean |
start()
Start the
FiniteStateMachine and enter the initial state. |
boolean |
stop()
Stops the
FiniteStateMachine as soon as possible. |
String getName()
FiniteStateMachine. This is primarily used for display/logging/monitoring purposes.FiniteStateMachinevoid process(Event<S> event)
FiniteStateMachine to process the specified Event.
Note: There's no guarantee that the Event will be processed because:
Transition to be performed for the Event is invalid as the FiniteStateMachine is not in the required starting state.FiniteStateMachine may have been stopped.event - the Event for the FiniteStateMachine to processS getState()
FiniteStateMachine.
Note: After returning the current state there's no guarantee that the state will be the same because a Transition may be executing asynchronously in the background on another thread.
FiniteStateMachinelong getTransitionCount()
FiniteStateMachine.
Note: After returning the count there's no guarantee that the count will be the same on the next request because a Transition may be executing asynchronously in the background on another thread.
FiniteStateMachineboolean start()
FiniteStateMachine and enter the initial state.
Note: Once stopped a FiniteStateMachine can't be restarted; instead a new FiniteStateMachine should be created.
true if the start was successful or the FiniteStateMachine is already stated, false if it has been stoppedIllegalStateException - if the FiniteStateMachine was already stoppedboolean stop()
FiniteStateMachine as soon as possible.
Note: Once stopped a FiniteStateMachine can't be restarted; instead a new FiniteStateMachine should be created.
true if the stop was successful, false if it's already stoppedIllegalStateException - if the FiniteStateMachine was never startedvoid addListener(FiniteStateMachineListener<S> listener)
FiniteStateMachineListener to the FiniteStateMachine.
Note that unique instances of FiniteStateMachineListener are identified via their #equals and #hashCode implementations.
listener - the listener to be addedvoid removeListener(FiniteStateMachineListener<S> listener)
FiniteStateMachineListener from the FiniteStateMachine.
Note that unique instances of FiniteStateMachineListener are identified via their #equals and #hashCode implementations.
listener - the listener to be removed