Interface FiniteStateMachine<S extends Enum<S>>
- Type Parameters:
 S- the type of state of the FiniteStateMachine
- All Known Implementing Classes:
 NonBlockingFiniteStateMachine
FiniteStateMachine implements a general purpose finite-state-machine.- Since:
 - Coherence 12.2.1
 - Author:
 - Brian Oliver
 - See Also:
 
- 
Method Summary
Modifier and TypeMethodDescriptionvoidaddListener(FiniteStateMachineListener<S> listener) Add aFiniteStateMachineListenerto theFiniteStateMachine.getName()Obtains the name of theFiniteStateMachine.getState()Obtains the current state of theFiniteStateMachine.longObtains the number of transitions that have occurred in theFiniteStateMachine.voidRequest theFiniteStateMachineto process the specifiedEvent.voidremoveListener(FiniteStateMachineListener<S> listener) Remove aFiniteStateMachineListenerfrom theFiniteStateMachine.booleanstart()Start theFiniteStateMachineand enter the initial state.booleanstop()Stops theFiniteStateMachineas soon as possible. 
- 
Method Details
- 
getName
String getName()Obtains the name of theFiniteStateMachine. This is primarily used for display/logging/monitoring purposes.- Returns:
 - the name of the 
FiniteStateMachine 
 - 
process
Request theFiniteStateMachineto process the specifiedEvent.Note: There's no guarantee that the
Eventwill be processed because:- the 
Transitionto be performed for theEventis invalid as theFiniteStateMachineis not in the required starting state. - the 
FiniteStateMachinemay have been stopped. 
- Parameters:
 event- theEventfor theFiniteStateMachineto process
 - the 
 - 
getState
S getState()Obtains the current state of theFiniteStateMachine.Note: After returning the current state there's no guarantee that the state will be the same because a
Transitionmay be executing asynchronously in the background on another thread.- Returns:
 - the current state of the 
FiniteStateMachine 
 - 
getTransitionCount
long getTransitionCount()Obtains the number of transitions that have occurred in theFiniteStateMachine.Note: After returning the count there's no guarantee that the count will be the same on the next request because a
Transitionmay be executing asynchronously in the background on another thread.- Returns:
 - the number of transitions that have occurred in the 
FiniteStateMachine 
 - 
start
boolean start()Start theFiniteStateMachineand enter the initial state.Note: Once stopped a
FiniteStateMachinecan't be restarted; instead a newFiniteStateMachineshould be created.- Returns:
 trueif the start was successful or the FiniteStateMachine is already stated,falseif it has been stopped- Throws:
 IllegalStateException- if the FiniteStateMachine was already stopped
 - 
stop
boolean stop()Stops theFiniteStateMachineas soon as possible.Note: Once stopped a
FiniteStateMachinecan't be restarted; instead a newFiniteStateMachineshould be created.- Returns:
 trueif the stop was successful,falseif it's already stopped- Throws:
 IllegalStateException- if the FiniteStateMachine was never started
 - 
addListener
Add aFiniteStateMachineListenerto theFiniteStateMachine.Note that unique instances of FiniteStateMachineListener are identified via their
equalsandhashCodeimplementations.- Parameters:
 listener- the listener to be added
 - 
removeListener
Remove aFiniteStateMachineListenerfrom theFiniteStateMachine.Note that unique instances of FiniteStateMachineListener are identified via their
equalsandhashCodeimplementations.- Parameters:
 listener- the listener to be removed
 
 -