Class DefaultStateContext<S,E>

java.lang.Object
org.springframework.statemachine.support.DefaultStateContext<S,E>
Type Parameters:
S - the type of state
E - the type of event
All Implemented Interfaces:
StateContext<S,E>

public class DefaultStateContext<S,E> extends Object implements StateContext<S,E>
Default implementation of a StateContext.
Author:
Janne Valkealahti
  • Constructor Details

    • DefaultStateContext

      public DefaultStateContext(StateContext.Stage stage, org.springframework.messaging.Message<E> message, org.springframework.messaging.MessageHeaders messageHeaders, ExtendedState extendedState, Transition<S,E> transition, StateMachine<S,E> stateMachine, State<S,E> source, State<S,E> target, Exception exception)
      Instantiates a new default state context.
      Parameters:
      stage - the stage
      message - the message
      messageHeaders - the message headers
      extendedState - the extended state
      transition - the transition
      stateMachine - the state machine
      source - the source
      target - the target
      exception - the exception
    • DefaultStateContext

      public DefaultStateContext(StateContext.Stage stage, org.springframework.messaging.Message<E> message, org.springframework.messaging.MessageHeaders messageHeaders, ExtendedState extendedState, Transition<S,E> transition, StateMachine<S,E> stateMachine, State<S,E> source, State<S,E> target, Collection<State<S,E>> sources, Collection<State<S,E>> targets, Exception exception)
      Instantiates a new default state context.
      Parameters:
      stage - the stage
      message - the message
      messageHeaders - the message headers
      extendedState - the extended state
      transition - the transition
      stateMachine - the state machine
      source - the source
      target - the target
      sources - the sources
      targets - the targets
      exception - the exception
  • Method Details

    • getStage

      public StateContext.Stage getStage()
      Description copied from interface: StateContext
      Gets the stage this context is attached.
      Specified by:
      getStage in interface StateContext<S,E>
      Returns:
      the stage
    • getEvent

      public E getEvent()
      Description copied from interface: StateContext
      Gets the event associated with a context. Event may be null if transition is not triggered by a signal.
      Specified by:
      getEvent in interface StateContext<S,E>
      Returns:
      the event
    • getMessage

      public org.springframework.messaging.Message<E> getMessage()
      Description copied from interface: StateContext
      Gets the message associated with a context. Message may be null if transition is not triggered by a signal.
      Specified by:
      getMessage in interface StateContext<S,E>
      Returns:
      the message
    • getMessageHeaders

      public org.springframework.messaging.MessageHeaders getMessageHeaders()
      Description copied from interface: StateContext
      Gets the event message headers.
      Specified by:
      getMessageHeaders in interface StateContext<S,E>
      Returns:
      the event message headers
    • getMessageHeader

      public Object getMessageHeader(Object header)
      Description copied from interface: StateContext
      Gets the message header. If header is not a String object's Object.toString() method is used to resolve a key name.
      Specified by:
      getMessageHeader in interface StateContext<S,E>
      Parameters:
      header - the header
      Returns:
      the message header
    • getExtendedState

      public ExtendedState getExtendedState()
      Description copied from interface: StateContext
      Gets the state machine extended state.
      Specified by:
      getExtendedState in interface StateContext<S,E>
      Returns:
      the state machine extended state
    • getTransition

      public Transition<S,E> getTransition()
      Description copied from interface: StateContext
      Gets the transition.
      Specified by:
      getTransition in interface StateContext<S,E>
      Returns:
      the transition
    • getStateMachine

      public StateMachine<S,E> getStateMachine()
      Description copied from interface: StateContext
      Gets the state machine.
      Specified by:
      getStateMachine in interface StateContext<S,E>
      Returns:
      the state machine
    • getSource

      public State<S,E> getSource()
      Description copied from interface: StateContext
      Gets the source state of this context. Generally source is where a state machine is coming from which may be different than what the transition source is.
      Specified by:
      getSource in interface StateContext<S,E>
      Returns:
      the source state
    • getSources

      public Collection<State<S,E>> getSources()
      Description copied from interface: StateContext
      Gets the source states of this context. Multiple sources are only valid during a context when machine is joining from multiple orthogonal regions.
      Specified by:
      getSources in interface StateContext<S,E>
      Returns:
      the source state
      See Also:
    • getTarget

      public State<S,E> getTarget()
      Description copied from interface: StateContext
      Gets the target state of this context. Generally target is where a state machine going to which may be different than what the transition target is.
      Specified by:
      getTarget in interface StateContext<S,E>
      Returns:
      the target state
    • getTargets

      public Collection<State<S,E>> getTargets()
      Description copied from interface: StateContext
      Gets the target states of this context. Multiple targets are only valid during a context when machine is forking into multiple orthogonal regions.
      Specified by:
      getTargets in interface StateContext<S,E>
      Returns:
      the target states
      See Also:
    • getException

      public Exception getException()
      Description copied from interface: StateContext
      Gets the exception associated with a context.
      Specified by:
      getException in interface StateContext<S,E>
      Returns:
      the exception
    • toString

      public String toString()
      Overrides:
      toString in class Object