S - the type of stateE - the type of eventpublic abstract class AbstractState<S,E> extends LifecycleObjectSupport implements State<S,E>
State.| Constructor and Description |
|---|
AbstractState(S id,
java.util.Collection<E> deferred)
Instantiates a new abstract state.
|
AbstractState(S id,
java.util.Collection<E> deferred,
java.util.Collection<? extends Action<S,E>> entryActions,
java.util.Collection<? extends Action<S,E>> exitActions)
Instantiates a new abstract state.
|
AbstractState(S id,
java.util.Collection<E> deferred,
java.util.Collection<? extends Action<S,E>> entryActions,
java.util.Collection<? extends Action<S,E>> exitActions,
java.util.Collection<? extends Action<S,E>> stateActions,
PseudoState<S,E> pseudoState,
java.util.Collection<Region<S,E>> regions,
StateMachine<S,E> submachine)
Instantiates a new abstract state.
|
AbstractState(S id,
java.util.Collection<E> deferred,
java.util.Collection<? extends Action<S,E>> entryActions,
java.util.Collection<? extends Action<S,E>> exitActions,
PseudoState<S,E> pseudoState)
Instantiates a new abstract state.
|
AbstractState(S id,
java.util.Collection<E> deferred,
java.util.Collection<? extends Action<S,E>> entryActions,
java.util.Collection<? extends Action<S,E>> exitActions,
PseudoState<S,E> pseudoState,
java.util.Collection<Region<S,E>> regions)
Instantiates a new abstract state.
|
AbstractState(S id,
java.util.Collection<E> deferred,
java.util.Collection<? extends Action<S,E>> entryActions,
java.util.Collection<? extends Action<S,E>> exitActions,
PseudoState<S,E> pseudoState,
java.util.Collection<Region<S,E>> regions,
StateMachine<S,E> submachine)
Instantiates a new abstract state.
|
AbstractState(S id,
java.util.Collection<E> deferred,
java.util.Collection<? extends Action<S,E>> entryActions,
java.util.Collection<? extends Action<S,E>> exitActions,
PseudoState<S,E> pseudoState,
StateMachine<S,E> submachine)
Instantiates a new abstract state.
|
AbstractState(S id,
PseudoState<S,E> pseudoState)
Instantiates a new abstract state.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addActionListener(ActionListener<S,E> listener)
Adds the action listener.
|
void |
addStateListener(StateListener<S,E> listener)
Adds the state listener.
|
protected void |
cancelStateActions()
Cancel existing state actions and clear list.
|
void |
entry(StateContext<S,E> context)
Initiate an entry sequence for the state.
|
protected void |
executeAction(Action<S,E> action,
StateContext<S,E> context)
Execute action and notify action listener if set.
|
void |
exit(StateContext<S,E> context)
Initiate an exit sequence for the state.
|
java.util.Collection<E> |
getDeferredEvents()
Gets the deferred events for this state.
|
java.util.Collection<? extends Action<S,E>> |
getEntryActions()
Gets
Actions executed entering in this state. |
java.util.Collection<? extends Action<S,E>> |
getExitActions()
Gets
Actions executed exiting from this state. |
S |
getId()
Gets the state identifier.
|
abstract java.util.Collection<S> |
getIds()
Gets the state identifiers.
|
PseudoState<S,E> |
getPseudoState()
Gets a
PseudoState attached to a State. |
java.util.Collection<Region<S,E>> |
getRegions()
Gets the regions.
|
abstract java.util.Collection<State<S,E>> |
getStates()
Gets all possible states this state knows about including itself
and substates.
|
StateMachine<S,E> |
getSubmachine()
Gets the submachine.
|
java.util.List<Trigger<S,E>> |
getTriggers()
Gets the triggers.
|
boolean |
isComposite()
Checks if state is a composite state.
|
boolean |
isOrthogonal()
Checks if state is an orthogonal state.
|
boolean |
isSimple()
Checks if state is a simple state.
|
boolean |
isSubmachineState()
Checks if state is a submachine state.
|
void |
removeActionListener(ActionListener<S,E> listener)
Removes the action listener.
|
void |
removeStateListener(StateListener<S,E> listener)
Removes the state listener.
|
protected java.util.concurrent.ScheduledFuture<?> |
scheduleAction(Action<S,E> action,
StateContext<S,E> context)
Schedule action and return future which can be used to cancel it.
|
protected void |
scheduleStateActions(StateContext<S,E> context)
Schedule state actions and store futures into list to
be cancelled.
|
boolean |
sendEvent(org.springframework.messaging.Message<E> event)
Send an event
E wrapped with a Message to the state. |
void |
setTriggers(java.util.List<Trigger<S,E>> triggers)
Sets the triggers.
|
boolean |
shouldDefer(org.springframework.messaging.Message<E> event)
Checks if state wants to defer an event.
|
java.lang.String |
toString() |
afterPropertiesSet, destroy, doDestroy, doStart, doStop, getBeanFactory, getPhase, getTaskExecutor, getTaskScheduler, isAutoStartup, isRunning, onInit, setAutoStartup, setBeanFactory, setPhase, setTaskExecutor, setTaskScheduler, start, stop, stoppublic AbstractState(S id, PseudoState<S,E> pseudoState)
id - the state identifierpseudoState - the pseudo statepublic AbstractState(S id, java.util.Collection<E> deferred)
id - the state identifierdeferred - the deferredpublic AbstractState(S id, java.util.Collection<E> deferred, java.util.Collection<? extends Action<S,E>> entryActions, java.util.Collection<? extends Action<S,E>> exitActions)
id - the state identifierdeferred - the deferredentryActions - the entry actionsexitActions - the exit actionspublic AbstractState(S id, java.util.Collection<E> deferred, java.util.Collection<? extends Action<S,E>> entryActions, java.util.Collection<? extends Action<S,E>> exitActions, PseudoState<S,E> pseudoState)
id - the state identifierdeferred - the deferredentryActions - the entry actionsexitActions - the exit actionspseudoState - the pseudo statepublic AbstractState(S id, java.util.Collection<E> deferred, java.util.Collection<? extends Action<S,E>> entryActions, java.util.Collection<? extends Action<S,E>> exitActions, PseudoState<S,E> pseudoState, StateMachine<S,E> submachine)
id - the state identifierdeferred - the deferredentryActions - the entry actionsexitActions - the exit actionspseudoState - the pseudo statesubmachine - the submachinepublic AbstractState(S id, java.util.Collection<E> deferred, java.util.Collection<? extends Action<S,E>> entryActions, java.util.Collection<? extends Action<S,E>> exitActions, PseudoState<S,E> pseudoState, java.util.Collection<Region<S,E>> regions)
id - the state identifierdeferred - the deferredentryActions - the entry actionsexitActions - the exit actionspseudoState - the pseudo stateregions - the regionspublic AbstractState(S id, java.util.Collection<E> deferred, java.util.Collection<? extends Action<S,E>> entryActions, java.util.Collection<? extends Action<S,E>> exitActions, PseudoState<S,E> pseudoState, java.util.Collection<Region<S,E>> regions, StateMachine<S,E> submachine)
id - the state identifierdeferred - the deferredentryActions - the entry actionsexitActions - the exit actionspseudoState - the pseudo stateregions - the regionssubmachine - the submachinepublic AbstractState(S id, java.util.Collection<E> deferred, java.util.Collection<? extends Action<S,E>> entryActions, java.util.Collection<? extends Action<S,E>> exitActions, java.util.Collection<? extends Action<S,E>> stateActions, PseudoState<S,E> pseudoState, java.util.Collection<Region<S,E>> regions, StateMachine<S,E> submachine)
id - the state identifierdeferred - the deferredentryActions - the entry actionsexitActions - the exit actionsstateActions - the state actionspseudoState - the pseudo stateregions - the regionssubmachine - the submachinepublic boolean sendEvent(org.springframework.messaging.Message<E> event)
StateE wrapped with a Message to the state.public boolean shouldDefer(org.springframework.messaging.Message<E> event)
StateshouldDefer in interface State<S,E>event - the wrapped eventpublic void exit(StateContext<S,E> context)
Statepublic void entry(StateContext<S,E> context)
Statepublic abstract java.util.Collection<S> getIds()
Statepublic abstract java.util.Collection<State<S,E>> getStates()
Statepublic PseudoState<S,E> getPseudoState()
StatePseudoState attached to a State.
PseudoState is not required and thus this method return
NULL if it's not set.getPseudoState in interface State<S,E>public java.util.Collection<E> getDeferredEvents()
StategetDeferredEvents in interface State<S,E>public java.util.Collection<? extends Action<S,E>> getEntryActions()
StateActions executed entering in this state.getEntryActions in interface State<S,E>public java.util.Collection<? extends Action<S,E>> getExitActions()
StateActions executed exiting from this state.getExitActions in interface State<S,E>public boolean isComposite()
StateisComposite in interface State<S,E>public boolean isOrthogonal()
StateTRUE,
State.isComposite() will also always return TRUE.isOrthogonal in interface State<S,E>public boolean isSimple()
Statepublic boolean isSubmachineState()
StateisSubmachineState in interface State<S,E>public void addStateListener(StateListener<S,E> listener)
StateaddStateListener in interface State<S,E>listener - the listenerpublic void removeStateListener(StateListener<S,E> listener)
StateremoveStateListener in interface State<S,E>listener - the listenerpublic void addActionListener(ActionListener<S,E> listener)
StateaddActionListener in interface State<S,E>listener - the listenerpublic void removeActionListener(ActionListener<S,E> listener)
StateremoveActionListener in interface State<S,E>listener - the listenerpublic StateMachine<S,E> getSubmachine()
public java.util.Collection<Region<S,E>> getRegions()
public void setTriggers(java.util.List<Trigger<S,E>> triggers)
triggers - the triggerspublic java.util.List<Trigger<S,E>> getTriggers()
protected void cancelStateActions()
protected void scheduleStateActions(StateContext<S,E> context)
context - the contextprotected void executeAction(Action<S,E> action, StateContext<S,E> context)
action - the actioncontext - the contextprotected java.util.concurrent.ScheduledFuture<?> scheduleAction(Action<S,E> action, StateContext<S,E> context)
action - the actioncontext - the contextpublic java.lang.String toString()
toString in class java.lang.Object