Interface Region<S,E>

Type Parameters:
S - the type of state
E - the type of event
All Superinterfaces:
StateMachineReactiveLifecycle
All Known Subinterfaces:
StateMachine<S,E>
All Known Implementing Classes:
AbstractStateMachine, DistributedStateMachine, ObjectStateMachine

public interface Region<S,E> extends StateMachineReactiveLifecycle
A region is an orthogonal part of either a composite state or a state machine. It contains states and transitions.
Author:
Janne Valkealahti
  • Method Details

    • getUuid

      UUID getUuid()
      Gets the region and state machine unique id.
      Returns:
      the region and state machine unique id
    • getId

      String getId()
      Gets the region and state machine id. This identifier is provided for users disposal and can be set from a various ways to build a machines.
      Returns:
      the region and state machine id
    • start

      @Deprecated void start()
      Start the region.
    • stop

      @Deprecated void stop()
      Stop the region.
    • sendEvent

      @Deprecated boolean sendEvent(org.springframework.messaging.Message<E> event)
      Deprecated.
      in favor of sendEvent(Mono)
      Send an event E wrapped with a Message to the region.

      NOTE: this method is now deprecated in favour of a reactive methods.

      Parameters:
      event - the wrapped event to send
      Returns:
      true if event was accepted
    • sendEvent

      @Deprecated boolean sendEvent(E event)
      Deprecated.
      in favor of sendEvent(Mono)
      Send an event E to the region.

      NOTE: this method is now deprecated in favour of a reactive methods.

      Parameters:
      event - the event to send
      Returns:
      true if event was accepted
    • sendEvents

      reactor.core.publisher.Flux<StateMachineEventResult<S,E>> sendEvents(reactor.core.publisher.Flux<org.springframework.messaging.Message<E>> events)
      Send a Flux of events and return a Flux of StateMachineEventResults. Events are consumed after returned results are consumed.
      Parameters:
      events - the events
      Returns:
      the event results
    • sendEvent

      reactor.core.publisher.Flux<StateMachineEventResult<S,E>> sendEvent(reactor.core.publisher.Mono<org.springframework.messaging.Message<E>> event)
      Send a Mono of event and return a Flux of StateMachineEventResults. Events are consumed after returned results are consumed.
      Parameters:
      event - the event
      Returns:
      the event results
    • sendEventCollect

      reactor.core.publisher.Mono<List<StateMachineEventResult<S,E>>> sendEventCollect(reactor.core.publisher.Mono<org.springframework.messaging.Message<E>> event)
      Send a Mono of event and return a Mono of collected StateMachineEventResults as a list. Events are consumed after returned results are consumed.
      Parameters:
      event - the event
      Returns:
      the event results
    • getState

      State<S,E> getState()
      Gets the current State.
      Returns:
      current state
    • getStates

      Collection<State<S,E>> getStates()
      Gets the States defined in this region. Returned collection is an unmodifiable copy because states in a state machine are immutable.
      Returns:
      immutable copy of states
    • getTransitions

      Collection<Transition<S,E>> getTransitions()
      Gets a Transitions for this region.
      Returns:
      immutable copy of transitions
    • isComplete

      boolean isComplete()
      Checks if region complete. Region is considered to be completed if it has reached its end state and no further event processing is happening.
      Returns:
      true, if complete
    • addStateListener

      void addStateListener(StateMachineListener<S,E> listener)
      Adds the state listener.
      Parameters:
      listener - the listener
    • removeStateListener

      void removeStateListener(StateMachineListener<S,E> listener)
      Removes the state listener.
      Parameters:
      listener - the listener