Interface State<S,E>
- Type Parameters:
S
- the type of stateE
- the type of event
- All Known Implementing Classes:
AbstractSimpleState
,AbstractState
,EnumState
,ObjectState
,RegionState
,StateMachineState
public interface State<S,E>
State
is an interface representing possible state in a state machine.-
Method Summary
Modifier and TypeMethodDescriptionvoid
addActionListener
(ActionListener<S, E> listener) Adds the action listener.void
addStateListener
(StateListener<S, E> listener) Adds the state listener.reactor.core.publisher.Mono<Void>
entry
(StateContext<S, E> context) Initiate an entry sequence for the state.reactor.core.publisher.Mono<Void>
exit
(StateContext<S, E> context) Initiate an exit sequence for the state.Gets the deferred events for this state.Collection<Function<StateContext<S,
E>, reactor.core.publisher.Mono<Void>>> GetsAction
s executed entering in this state.Collection<Function<StateContext<S,
E>, reactor.core.publisher.Mono<Void>>> GetsAction
s executed exiting from this state.getId()
Gets the state identifier.getIds()
Gets the state identifiers.Gets aPseudoState
attached to aState
.Collection<Function<StateContext<S,
E>, reactor.core.publisher.Mono<Void>>> GetsAction
s executed once in this state.Collection<State<S,
E>> Gets all possible states this state knows about including itself and substates.boolean
Checks if state is a composite state.boolean
Checks if state is an orthogonal state.boolean
isSimple()
Checks if state is a simple state.boolean
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.reactor.core.publisher.Flux<StateMachineEventResult<S,
E>> Send an eventE
wrapped with aMessage
to the state and return aStateMachineEventResult
for results.boolean
shouldDefer
(org.springframework.messaging.Message<E> event) Checks if state wants to defer an event.
-
Method Details
-
sendEvent
reactor.core.publisher.Flux<StateMachineEventResult<S,E>> sendEvent(org.springframework.messaging.Message<E> event) Send an eventE
wrapped with aMessage
to the state and return aStateMachineEventResult
for results.- Parameters:
event
- the wrapped event to send- Returns:
- the state machine event results
-
shouldDefer
Checks if state wants to defer an event.- Parameters:
event
- the wrapped event- Returns:
- true if event should be deferred
-
exit
Initiate an exit sequence for the state.- Parameters:
context
- the state context- Returns:
- Mono for completion
-
entry
Initiate an entry sequence for the state.- Parameters:
context
- the state context- Returns:
- Mono for completion
-
getId
S getId()Gets the state identifier.- Returns:
- the state identifiers
-
getIds
Collection<S> getIds()Gets the state identifiers. Usually returned collection contains only one identifier except in a case where state is an orthogonal.- Returns:
- the state identifiers
-
getStates
Collection<State<S,E>> getStates()Gets all possible states this state knows about including itself and substates.- Returns:
- all state including itself and nested states
-
getPseudoState
PseudoState<S,E> getPseudoState()Gets aPseudoState
attached to aState
.PseudoState
is not required and thus this method returnNULL
if it's not set.- Returns:
- pseudostate or null if state doesn't have one
-
getDeferredEvents
Collection<E> getDeferredEvents()Gets the deferred events for this state.- Returns:
- the state deferred events
-
getEntryActions
Collection<Function<StateContext<S,E>, getEntryActions()reactor.core.publisher.Mono<Void>>> GetsAction
s executed entering in this state.- Returns:
- the state entry actions
-
getStateActions
Collection<Function<StateContext<S,E>, getStateActions()reactor.core.publisher.Mono<Void>>> GetsAction
s executed once in this state.- Returns:
- the state actions
-
getExitActions
Collection<Function<StateContext<S,E>, getExitActions()reactor.core.publisher.Mono<Void>>> GetsAction
s executed exiting from this state.- Returns:
- the state exit actions
-
isSimple
boolean isSimple()Checks if state is a simple state. A simple state does not have any regions and it does not refer to any submachine state machine.- Returns:
- true, if state is a simple state
-
isComposite
boolean isComposite()Checks if state is a composite state. A composite state is a state that contains at least one region.- Returns:
- true, if state is a composite state
-
isOrthogonal
boolean isOrthogonal()Checks if state is an orthogonal state. An orthogonal composite state contains two or more regions. If this method returnsTRUE
,isComposite()
will also always returnTRUE
.- Returns:
- true, if state is an orthogonal state
-
isSubmachineState
boolean isSubmachineState()Checks if state is a submachine state. This kind of state refers to a state machine(submachine).- Returns:
- true, if state is a submachine state
-
addStateListener
Adds the state listener.- Parameters:
listener
- the listener
-
removeStateListener
Removes the state listener.- Parameters:
listener
- the listener
-
addActionListener
Adds the action listener.- Parameters:
listener
- the listener
-
removeActionListener
Removes the action listener.- Parameters:
listener
- the listener
-