Class StateMachineState<S,E>

Type Parameters:
S - the type of state
E - the type of event
All Implemented Interfaces:
org.springframework.beans.factory.Aware, org.springframework.beans.factory.BeanFactoryAware, org.springframework.beans.factory.DisposableBean, org.springframework.beans.factory.InitializingBean, org.springframework.context.Lifecycle, org.springframework.context.Phased, org.springframework.context.SmartLifecycle, State<S,E>, StateMachineReactiveLifecycle

public class StateMachineState<S,E> extends AbstractState<S,E>
A State implementation where state is wrapped in a substatemachine.
Author:
Janne Valkealahti
  • Constructor Details

    • StateMachineState

      public StateMachineState(S id, StateMachine<S,E> submachine)
      Instantiates a new state machine state.
      Parameters:
      id - the state identifier
      submachine - the submachine
    • StateMachineState

      public StateMachineState(S id, StateMachine<S,E> submachine, Collection<E> deferred)
      Instantiates a new state machine state.
      Parameters:
      id - the state identifier
      submachine - the submachine
      deferred - the deferred
    • StateMachineState

      public StateMachineState(S id, StateMachine<S,E> submachine, PseudoState<S,E> pseudoState)
      Instantiates a new state machine state.
      Parameters:
      id - the state identifier
      submachine - the submachine
      pseudoState - the pseudo state
    • StateMachineState

      public StateMachineState(S id, StateMachine<S,E> submachine, Collection<E> deferred, Collection<Function<StateContext<S,E>,reactor.core.publisher.Mono<Void>>> entryActions, Collection<Function<StateContext<S,E>,reactor.core.publisher.Mono<Void>>> exitActions, PseudoState<S,E> pseudoState)
      Instantiates a new state machine state.
      Parameters:
      id - the state identifier
      submachine - the submachine
      deferred - the deferred
      entryActions - the entry actions
      exitActions - the exit actions
      pseudoState - the pseudo state
    • StateMachineState

      public StateMachineState(S id, StateMachine<S,E> submachine, Collection<E> deferred, Collection<Function<StateContext<S,E>,reactor.core.publisher.Mono<Void>>> entryActions, Collection<Function<StateContext<S,E>,reactor.core.publisher.Mono<Void>>> exitActions)
      Instantiates a new state machine state.
      Parameters:
      id - the state identifier
      submachine - the submachine
      deferred - the deferred
      entryActions - the entry actions
      exitActions - the exit actions
  • Method Details

    • getIds

      public Collection<S> getIds()
      Description copied from interface: State
      Gets the state identifiers. Usually returned collection contains only one identifier except in a case where state is an orthogonal.
      Specified by:
      getIds in interface State<S,E>
      Specified by:
      getIds in class AbstractState<S,E>
      Returns:
      the state identifiers
    • getStates

      public Collection<State<S,E>> getStates()
      Description copied from interface: State
      Gets all possible states this state knows about including itself and substates.
      Specified by:
      getStates in interface State<S,E>
      Specified by:
      getStates in class AbstractState<S,E>
      Returns:
      all state including itself and nested states
    • exit

      public reactor.core.publisher.Mono<Void> exit(StateContext<S,E> context)
      Description copied from interface: State
      Initiate an exit sequence for the state.
      Specified by:
      exit in interface State<S,E>
      Overrides:
      exit in class AbstractState<S,E>
      Parameters:
      context - the state context
      Returns:
      Mono for completion
    • entry

      public reactor.core.publisher.Mono<Void> entry(StateContext<S,E> context)
      Description copied from interface: State
      Initiate an entry sequence for the state.
      Specified by:
      entry in interface State<S,E>
      Overrides:
      entry in class AbstractState<S,E>
      Parameters:
      context - the state context
      Returns:
      Mono for completion
    • sendEvent

      public reactor.core.publisher.Flux<StateMachineEventResult<S,E>> sendEvent(org.springframework.messaging.Message<E> event)
      Description copied from interface: State
      Send an event E wrapped with a Message to the state and return a StateMachineEventResult for results.
      Specified by:
      sendEvent in interface State<S,E>
      Overrides:
      sendEvent in class AbstractState<S,E>
      Parameters:
      event - the wrapped event to send
      Returns:
      the state machine event results
    • shouldDefer

      public boolean shouldDefer(org.springframework.messaging.Message<E> event)
      Description copied from interface: State
      Checks if state wants to defer an event.
      Specified by:
      shouldDefer in interface State<S,E>
      Overrides:
      shouldDefer in class AbstractState<S,E>
      Parameters:
      event - the wrapped event
      Returns:
      true if event should be deferred
    • toString

      public String toString()
      Overrides:
      toString in class AbstractState<S,E>