Package org.eclipse.net4j.util.fsm
Class FiniteStateMachine<STATE extends Enum<?>,EVENT extends Enum<?>,SUBJECT>
java.lang.Object
org.eclipse.net4j.util.event.Notifier
org.eclipse.net4j.util.lifecycle.Lifecycle
org.eclipse.net4j.util.fsm.FiniteStateMachine<STATE,EVENT,SUBJECT>
- All Implemented Interfaces:
INotifier
,INotifier.INotifier2
,IDeactivateable
,ILifecycle
,ILifecycle.DeferrableActivation
- Direct Known Subclasses:
Negotiator
public abstract class FiniteStateMachine<STATE extends Enum<?>,EVENT extends Enum<?>,SUBJECT>
extends Lifecycle
A finite state machine that is based on a matrix of
transitions
.
A finite state machine can fire the following events:
-
FiniteStateMachine<STATE extends Enum<?>,
after state changes of a subject.EVENT extends Enum<?>, SUBJECT>.StateChangedEvent
- Author:
- Eike Stepper
-
Nested Class Summary
Modifier and TypeClassDescriptionclass
Atransition
that changes thestate
of a subject.static class
Deprecated.static class
Deprecated.UseIGNORE
class
Nested classes/interfaces inherited from interface org.eclipse.net4j.util.lifecycle.ILifecycle
ILifecycle.DeferrableActivation
Nested classes/interfaces inherited from interface org.eclipse.net4j.util.event.INotifier
INotifier.INotifier2
-
Field Summary
-
Constructor Summary
ConstructorDescriptionFiniteStateMachine
(Class<STATE> stateEnum, Class<EVENT> eventEnum) FiniteStateMachine
(Class<STATE> stateEnum, Class<EVENT> eventEnum, ITransition<STATE, EVENT, SUBJECT, ?> defaultTransition) -
Method Summary
Modifier and TypeMethodDescriptionprotected STATE
changeState
(SUBJECT subject, STATE state) protected ITransition<STATE,
EVENT, SUBJECT, ?> createFailTransition
(STATE state, EVENT event) protected ITransition<STATE,
EVENT, SUBJECT, ?> createIgnoreTransition
(STATE state, EVENT event) void
dump
(PrintStream out) protected String
formatFailMessage
(SUBJECT subject, STATE state, EVENT event, Object data) protected String
formatIgnoreMessage
(SUBJECT subject, STATE state, EVENT event, Object data) protected String
formatProcessMessage
(SUBJECT subject, STATE state, EVENT event, Object data) final EVENT[]
protected abstract STATE
final STATE[]
final ITransition<STATE,
EVENT, SUBJECT, ?> getTransition
(STATE state, EVENT event) final void
final void
final void
initAll
(ITransition<STATE, EVENT, SUBJECT, ?> transition) final void
final void
initEvents
(STATE state, ITransition<STATE, EVENT, SUBJECT, ?> transition) final void
initEvents
(STATE state, STATE targetState) final void
initStates
(EVENT event, ITransition<STATE, EVENT, SUBJECT, ?> transition) final void
initStates
(EVENT event, STATE targetState) final <DATA> void
protected abstract void
Methods inherited from class org.eclipse.net4j.util.lifecycle.Lifecycle
activate, checkActive, checkArg, checkArg, checkInactive, checkNull, checkState, checkState, deactivate, deferredActivate, doActivate, doAfterActivate, doBeforeActivate, doBeforeDeactivate, doDeactivate, dump, getLifecycleState, isActive, isDeferredActivation, toString
Methods inherited from class org.eclipse.net4j.util.event.Notifier
addListener, addUniqueListener, fireEvent, fireEvent, fireEvent, fireThrowable, firstListenerAdded, getListeners, getNotificationService, hasListener, hasListeners, lastListenerRemoved, listenerAdded, listenerRemoved, removeListener
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.eclipse.net4j.util.event.INotifier
addListener, getListeners, hasListeners, removeListener
-
Field Details
-
IGNORE
-
FAIL
-
-
Constructor Details
-
FiniteStateMachine
-
FiniteStateMachine
-
-
Method Details
-
getStates
-
getEvents
-
getTransition
-
init
-
init
-
initEvents
-
initEvents
-
initStates
-
initStates
-
initAll
-
initAll
-
process
-
dump
- Since:
- 3.25
-
createIgnoreTransition
-
createFailTransition
-
formatProcessMessage
-
formatIgnoreMessage
-
formatFailMessage
-
getState
-
setState
-
changeState
- Since:
- 3.0
-
FAIL