public abstract class FiniteStateMachine<STATE extends Enum<?>,EVENT extends Enum<?>,SUBJECT> extends Lifecycle
transitions
.
A finite state machine can fire the following events:
FiniteStateMachine.StateChangedEvent
after state changes of a subject.
Modifier and Type | Class and Description |
---|---|
class |
FiniteStateMachine.ChangeStateTransition
A
transition that changes the state of a subject. |
static class |
FiniteStateMachine.FailTransition
Deprecated.
Use
FAIL |
static class |
FiniteStateMachine.IgnoreTransition
Deprecated.
Use
IGNORE |
class |
FiniteStateMachine.StateChangedEvent |
ILifecycle.DeferrableActivation
Modifier and Type | Field and Description |
---|---|
static ITransition |
FAIL |
static ITransition |
IGNORE |
Constructor and Description |
---|
FiniteStateMachine(Class<STATE> stateEnum,
Class<EVENT> eventEnum) |
FiniteStateMachine(Class<STATE> stateEnum,
Class<EVENT> eventEnum,
ITransition<STATE,EVENT,SUBJECT,?> defaultTransition) |
Modifier and Type | Method and Description |
---|---|
protected 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) |
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) |
EVENT[] |
getEvents() |
protected abstract STATE |
getState(SUBJECT subject) |
STATE[] |
getStates() |
ITransition<STATE,EVENT,SUBJECT,?> |
getTransition(STATE state,
EVENT event) |
void |
init(STATE state,
EVENT event,
ITransition<STATE,EVENT,SUBJECT,?> transition) |
void |
init(STATE state,
EVENT event,
STATE targetState) |
void |
initAll(ITransition<STATE,EVENT,SUBJECT,?> transition) |
void |
initAll(STATE targetState) |
void |
initEvents(STATE state,
ITransition<STATE,EVENT,SUBJECT,?> transition) |
void |
initEvents(STATE state,
STATE targetState) |
void |
initStates(EVENT event,
ITransition<STATE,EVENT,SUBJECT,?> transition) |
void |
initStates(EVENT event,
STATE targetState) |
<DATA> void |
process(SUBJECT subject,
EVENT event,
DATA data) |
protected abstract void |
setState(SUBJECT subject,
STATE state) |
activate, checkActive, checkArg, checkArg, checkInactive, checkNull, checkState, checkState, deactivate, deferredActivate, doActivate, doAfterActivate, doBeforeActivate, doBeforeDeactivate, doDeactivate, dump, getLifecycleState, isActive, isDeferredActivation, toString
addListener, fireEvent, fireEvent, fireEvent, fireThrowable, firstListenerAdded, getListeners, getNotificationService, hasListeners, lastListenerRemoved, removeListener
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
addListener, getListeners, hasListeners, removeListener
public static final ITransition IGNORE
public static final ITransition FAIL
public FiniteStateMachine(Class<STATE> stateEnum, Class<EVENT> eventEnum, ITransition<STATE,EVENT,SUBJECT,?> defaultTransition)
public final STATE[] getStates()
public final EVENT[] getEvents()
public final ITransition<STATE,EVENT,SUBJECT,?> getTransition(STATE state, EVENT event)
public final void init(STATE state, EVENT event, ITransition<STATE,EVENT,SUBJECT,?> transition)
public final void initEvents(STATE state, ITransition<STATE,EVENT,SUBJECT,?> transition)
public final void initStates(EVENT event, ITransition<STATE,EVENT,SUBJECT,?> transition)
public final void initAll(STATE targetState)
public final void initAll(ITransition<STATE,EVENT,SUBJECT,?> transition)
protected ITransition<STATE,EVENT,SUBJECT,?> createIgnoreTransition(STATE state, EVENT event)
protected ITransition<STATE,EVENT,SUBJECT,?> createFailTransition(STATE state, EVENT event)
protected String formatProcessMessage(SUBJECT subject, STATE state, EVENT event, Object data)
protected String formatIgnoreMessage(SUBJECT subject, STATE state, EVENT event, Object data)
protected String formatFailMessage(SUBJECT subject, STATE state, EVENT event, Object data)
Copyright (c) 2011, 2012 Eike Stepper (Berlin, Germany) and others.