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<java.util.function.Function<StateContext<S,E>,reactor.core.publisher.Mono<java.lang.Void>>> entryActions,
java.util.Collection<java.util.function.Function<StateContext<S,E>,reactor.core.publisher.Mono<java.lang.Void>>> exitActions)
Instantiates a new abstract state.
|
AbstractState(S id,
java.util.Collection<E> deferred,
java.util.Collection<java.util.function.Function<StateContext<S,E>,reactor.core.publisher.Mono<java.lang.Void>>> entryActions,
java.util.Collection<java.util.function.Function<StateContext<S,E>,reactor.core.publisher.Mono<java.lang.Void>>> exitActions,
java.util.Collection<java.util.function.Function<StateContext<S,E>,reactor.core.publisher.Mono<java.lang.Void>>> 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<java.util.function.Function<StateContext<S,E>,reactor.core.publisher.Mono<java.lang.Void>>> entryActions,
java.util.Collection<java.util.function.Function<StateContext<S,E>,reactor.core.publisher.Mono<java.lang.Void>>> exitActions,
PseudoState<S,E> pseudoState)
Instantiates a new abstract state.
|
AbstractState(S id,
java.util.Collection<E> deferred,
java.util.Collection<java.util.function.Function<StateContext<S,E>,reactor.core.publisher.Mono<java.lang.Void>>> entryActions,
java.util.Collection<java.util.function.Function<StateContext<S,E>,reactor.core.publisher.Mono<java.lang.Void>>> 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<java.util.function.Function<StateContext<S,E>,reactor.core.publisher.Mono<java.lang.Void>>> entryActions,
java.util.Collection<java.util.function.Function<StateContext<S,E>,reactor.core.publisher.Mono<java.lang.Void>>> 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<java.util.function.Function<StateContext<S,E>,reactor.core.publisher.Mono<java.lang.Void>>> entryActions,
java.util.Collection<java.util.function.Function<StateContext<S,E>,reactor.core.publisher.Mono<java.lang.Void>>> 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 |
armTriggers()
Arm triggers.
|
protected void |
disarmTriggers()
Disarm triggers.
|
protected reactor.core.publisher.Mono<java.lang.Void> |
doPreStartReactively()
Subclasses may implement this for pre start logic.
|
protected reactor.core.publisher.Mono<java.lang.Void> |
doPreStopReactively()
Subclasses may implement this for pre stop logic.
|
reactor.core.publisher.Mono<java.lang.Void> |
entry(StateContext<S,E> context)
Initiate an entry sequence for the state.
|
protected reactor.core.publisher.Mono<java.lang.Void> |
executeAction(java.util.function.Function<StateContext<S,E>,reactor.core.publisher.Mono<java.lang.Void>> action,
StateContext<S,E> context)
Execute action and notify action listener if set.
|
reactor.core.publisher.Mono<java.lang.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<java.util.function.Function<StateContext<S,E>,reactor.core.publisher.Mono<java.lang.Void>>> |
getEntryActions()
Gets
Action s executed entering in this state. |
java.util.Collection<java.util.function.Function<StateContext<S,E>,reactor.core.publisher.Mono<java.lang.Void>>> |
getExitActions()
Gets
Action s 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.
|
java.util.Collection<java.util.function.Function<StateContext<S,E>,reactor.core.publisher.Mono<java.lang.Void>>> |
getStateActions()
Gets
Action s executed once in this state. |
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.
|
protected reactor.core.publisher.Mono<java.lang.Void> |
handleStateDoOnComplete(StateContext<S,E> context) |
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.
|
protected void |
notifyStateOnComplete(StateContext<S,E> context) |
void |
removeActionListener(ActionListener<S,E> listener)
Removes the action listener.
|
void |
removeStateListener(StateListener<S,E> listener)
Removes the state listener.
|
reactor.core.publisher.Flux<StateMachineEventResult<S,E>> |
sendEvent(org.springframework.messaging.Message<E> event)
Send an event
E wrapped with a Message to the state and
return a StateMachineEventResult for results. |
void |
setStateDoActionPolicy(StateDoActionPolicy stateDoActionPolicy) |
void |
setStateDoActionPolicyTimeout(java.lang.Long stateDoActionPolicyTimeout) |
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, doPostStartReactively, doPostStopReactively, getBeanFactory, getPhase, isAutoStartup, isRunning, onInit, setAutoStartup, setBeanFactory, setPhase, start, startReactively, stop, stopReactively
public 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<java.util.function.Function<StateContext<S,E>,reactor.core.publisher.Mono<java.lang.Void>>> entryActions, java.util.Collection<java.util.function.Function<StateContext<S,E>,reactor.core.publisher.Mono<java.lang.Void>>> exitActions)
id
- the state identifierdeferred
- the deferredentryActions
- the entry actionsexitActions
- the exit actionspublic AbstractState(S id, java.util.Collection<E> deferred, java.util.Collection<java.util.function.Function<StateContext<S,E>,reactor.core.publisher.Mono<java.lang.Void>>> entryActions, java.util.Collection<java.util.function.Function<StateContext<S,E>,reactor.core.publisher.Mono<java.lang.Void>>> 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<java.util.function.Function<StateContext<S,E>,reactor.core.publisher.Mono<java.lang.Void>>> entryActions, java.util.Collection<java.util.function.Function<StateContext<S,E>,reactor.core.publisher.Mono<java.lang.Void>>> 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<java.util.function.Function<StateContext<S,E>,reactor.core.publisher.Mono<java.lang.Void>>> entryActions, java.util.Collection<java.util.function.Function<StateContext<S,E>,reactor.core.publisher.Mono<java.lang.Void>>> 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<java.util.function.Function<StateContext<S,E>,reactor.core.publisher.Mono<java.lang.Void>>> entryActions, java.util.Collection<java.util.function.Function<StateContext<S,E>,reactor.core.publisher.Mono<java.lang.Void>>> 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<java.util.function.Function<StateContext<S,E>,reactor.core.publisher.Mono<java.lang.Void>>> entryActions, java.util.Collection<java.util.function.Function<StateContext<S,E>,reactor.core.publisher.Mono<java.lang.Void>>> exitActions, java.util.Collection<java.util.function.Function<StateContext<S,E>,reactor.core.publisher.Mono<java.lang.Void>>> 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 reactor.core.publisher.Flux<StateMachineEventResult<S,E>> sendEvent(org.springframework.messaging.Message<E> event)
State
E
wrapped with a Message
to the state and
return a StateMachineEventResult
for results.public boolean shouldDefer(org.springframework.messaging.Message<E> event)
State
shouldDefer
in interface State<S,E>
event
- the wrapped eventpublic reactor.core.publisher.Mono<java.lang.Void> exit(StateContext<S,E> context)
State
public reactor.core.publisher.Mono<java.lang.Void> entry(StateContext<S,E> context)
State
public abstract java.util.Collection<S> getIds()
State
public abstract java.util.Collection<State<S,E>> getStates()
State
public PseudoState<S,E> getPseudoState()
State
PseudoState
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()
State
getDeferredEvents
in interface State<S,E>
public java.util.Collection<java.util.function.Function<StateContext<S,E>,reactor.core.publisher.Mono<java.lang.Void>>> getEntryActions()
State
Action
s executed entering in this state.getEntryActions
in interface State<S,E>
public java.util.Collection<java.util.function.Function<StateContext<S,E>,reactor.core.publisher.Mono<java.lang.Void>>> getStateActions()
State
Action
s executed once in this state.getStateActions
in interface State<S,E>
public java.util.Collection<java.util.function.Function<StateContext<S,E>,reactor.core.publisher.Mono<java.lang.Void>>> getExitActions()
State
Action
s executed exiting from this state.getExitActions
in interface State<S,E>
public boolean isComposite()
State
isComposite
in interface State<S,E>
public boolean isOrthogonal()
State
TRUE
,
State.isComposite()
will also always return TRUE
.isOrthogonal
in interface State<S,E>
public boolean isSimple()
State
public boolean isSubmachineState()
State
isSubmachineState
in interface State<S,E>
public void addStateListener(StateListener<S,E> listener)
State
addStateListener
in interface State<S,E>
listener
- the listenerpublic void removeStateListener(StateListener<S,E> listener)
State
removeStateListener
in interface State<S,E>
listener
- the listenerpublic void addActionListener(ActionListener<S,E> listener)
State
addActionListener
in interface State<S,E>
listener
- the listenerpublic void removeActionListener(ActionListener<S,E> listener)
State
removeActionListener
in interface State<S,E>
listener
- the listenerprotected reactor.core.publisher.Mono<java.lang.Void> doPreStartReactively()
LifecycleObjectSupport
doPreStartReactively
in class LifecycleObjectSupport
protected reactor.core.publisher.Mono<java.lang.Void> doPreStopReactively()
LifecycleObjectSupport
doPreStopReactively
in class LifecycleObjectSupport
public 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()
public void setStateDoActionPolicy(StateDoActionPolicy stateDoActionPolicy)
public void setStateDoActionPolicyTimeout(java.lang.Long stateDoActionPolicyTimeout)
protected void armTriggers()
protected void disarmTriggers()
protected reactor.core.publisher.Mono<java.lang.Void> executeAction(java.util.function.Function<StateContext<S,E>,reactor.core.publisher.Mono<java.lang.Void>> action, StateContext<S,E> context)
action
- the actioncontext
- the contextprotected reactor.core.publisher.Mono<java.lang.Void> handleStateDoOnComplete(StateContext<S,E> context)
protected void notifyStateOnComplete(StateContext<S,E> context)
public java.lang.String toString()
toString
in class java.lang.Object