Class StateDecision

java.lang.Object
io.iworkflow.core.StateDecision

@Immutable public abstract class StateDecision extends Object
  • Constructor Details

    • StateDecision

      public StateDecision()
  • Method Details

    • getWorkflowConditionalClose

      public abstract Optional<InternalConditionalClose> getWorkflowConditionalClose()
    • getNextStates

      public abstract List<StateMovement> getNextStates()
    • deadEnd

      public static StateDecision deadEnd()
    • builder

      public static io.iworkflow.core.ImmutableStateDecision.Builder builder()
    • gracefulCompleteWorkflow

      public static StateDecision gracefulCompleteWorkflow(Object completionOutput)
    • gracefulCompleteWorkflow

      public static StateDecision gracefulCompleteWorkflow()
    • forceCompleteWorkflow

      public static StateDecision forceCompleteWorkflow(Object completionOutput)
    • forceCompleteWorkflow

      public static StateDecision forceCompleteWorkflow()
    • forceFailWorkflow

      public static StateDecision forceFailWorkflow(Object completionOutput)
    • forceFailWorkflow

      public static StateDecision forceFailWorkflow()
    • forceCompleteIfInternalChannelEmptyOrElse

      public static <I> StateDecision forceCompleteIfInternalChannelEmptyOrElse(String internalChannelName, Class<? extends WorkflowState<I>> orElseStateClass)
    • forceCompleteIfInternalChannelEmptyOrElse

      public static <I> StateDecision forceCompleteIfInternalChannelEmptyOrElse(String internalChannelName, Class<? extends WorkflowState<I>> orElseStateClass, I stateInput)
    • forceCompleteIfInternalChannelEmptyOrElse

      public static <I> StateDecision forceCompleteIfInternalChannelEmptyOrElse(Object completionOutput, String internalChannelName, Class<? extends WorkflowState<I>> orElseStateClass)
    • forceCompleteIfInternalChannelEmptyOrElse

      public static <I> StateDecision forceCompleteIfInternalChannelEmptyOrElse(Object completionOutput, String internalChannelName, Class<? extends WorkflowState<I>> orElseStateClass, I stateInput)
    • forceCompleteIfInternalChannelEmptyOrElse

      public static StateDecision forceCompleteIfInternalChannelEmptyOrElse(Object completionOutput, String internalChannelName, StateMovement... orElseStateMovements)
      Atomically force complete the workflow if internal channel is empty, otherwise trigger the state movements from the current thread This is important for use case that needs to ensure all the messages in the channel are processed before completing the workflow, otherwise messages will be lost. Without this atomic API, if user just check the channel emptiness in the State APIs, the channel may receive new messages during the execution of state APIs
      Parameters:
      completionOutput - the output of workflow completion
      internalChannelName - the internal channel name for checking emptiness
      orElseStateMovements - the state movements if channel is not empty
      Returns:
      the decision
    • forceCompleteIfSignalChannelEmptyOrElse

      public static <I> StateDecision forceCompleteIfSignalChannelEmptyOrElse(String signalChannelName, Class<? extends WorkflowState<I>> orElseStateClass)
    • forceCompleteIfSignalChannelEmptyOrElse

      public static <I> StateDecision forceCompleteIfSignalChannelEmptyOrElse(String signalChannelName, Class<? extends WorkflowState<I>> orElseStateClass, I stateInput)
    • forceCompleteIfSignalChannelEmptyOrElse

      public static <I> StateDecision forceCompleteIfSignalChannelEmptyOrElse(Object completionOutput, String signalChannelName, Class<? extends WorkflowState<I>> orElseStateClass)
    • forceCompleteIfSignalChannelEmptyOrElse

      public static <I> StateDecision forceCompleteIfSignalChannelEmptyOrElse(Object completionOutput, String signalChannelName, Class<? extends WorkflowState<I>> orElseStateClass, I stateInput)
    • forceCompleteIfSignalChannelEmptyOrElse

      public static StateDecision forceCompleteIfSignalChannelEmptyOrElse(Object completionOutput, String signalChannelName, StateMovement... orElseStateMovements)
      Atomically force complete the workflow if signal channel is empty, otherwise trigger the state movements from the current thread This is important for use case that needs to ensure all the messages in the channel are processed before completing the workflow, otherwise messages will be lost. Without this atomic API, if user just check the channel emptiness in the State APIs, the channel may receive new messages during the execution of state APIs
      Parameters:
      completionOutput - the output of workflow completion
      signalChannelName - the signal channel name for checking emptiness
      orElseStateMovements - the state movements if channel is not empty
      Returns:
      the decision
    • singleNextState

      public static <I> StateDecision singleNextState(Class<? extends WorkflowState<I>> stateClass, I stateInput, WorkflowStateOptions stateOptionsOverride)
      Type Parameters:
      I - Class type of the WorkflowState input
      Parameters:
      stateClass - required
      stateInput - optional, can be null
      stateOptionsOverride - optional, can be null. It is used to override the defined one in the State class
      Returns:
      state decision
    • singleNextState

      public static <I> StateDecision singleNextState(Class<? extends WorkflowState<I>> stateClass, I stateInput)
      Type Parameters:
      I - Class type of the WorkflowState input
      Parameters:
      stateClass - required
      stateInput - optional, can be null
      Returns:
      state decision
    • singleNextState

      public static <I> StateDecision singleNextState(Class<? extends WorkflowState<I>> stateClass, I stateInput, String waitForKey)
      Type Parameters:
      I - Class type of the WorkflowState input
      Parameters:
      stateClass - required
      stateInput - optional, can be null
      waitForKey - key awaited at state completion
      Returns:
      state decision
    • singleNextStateUntypedInput

      public static StateDecision singleNextStateUntypedInput(Class<? extends WorkflowState> stateClass, Object stateInput)
      singleNextState as non-strongly typing required for input
      Parameters:
      stateClass - required
      stateInput - optional, can be null
      Returns:
      state decision
    • singleNextState

      public static <I> StateDecision singleNextState(Class<? extends WorkflowState<I>> stateClass)
      Type Parameters:
      I - Class type of the WorkflowState input
      Parameters:
      stateClass - required
      Returns:
      state decision
    • singleNextState

      public static StateDecision singleNextState(String stateId, Object stateInput, WorkflowStateOptions stateOptionsOverride)
      use the other one with WorkflowState class param if the stateId is provided by default, to make your code cleaner
      Parameters:
      stateId - required. StateId of next state
      stateInput - optional, can be null. Input for next state
      stateOptionsOverride - optional, can be null. It is used to override the defined one in the State class
      Returns:
      state decision
    • singleNextState

      public static StateDecision singleNextState(String stateId, Object stateInput, WorkflowStateOptions stateOptionsOverride, String waitForKey)
      use the other one with WorkflowState class param if the stateId is provided by default, to make your code cleaner
      Parameters:
      stateId - required. StateId of next state
      stateInput - optional, can be null. Input for next state
      stateOptionsOverride - optional, can be null. It is used to override the defined one in the State class
      waitForKey - key awaited at state completion
      Returns:
      state decision
    • singleNextState

      public static StateDecision singleNextState(String stateId)
      use the other one with WorkflowState class param if the stateId is provided by default, to make your code cleaner
      Parameters:
      stateId - stateId of next state
      Returns:
      state decision
    • multiNextStates

      public static StateDecision multiNextStates(List<StateMovement> stateMovements)
      Parameters:
      stateMovements - required
      Returns:
      state decision
    • multiNextStates

      public static StateDecision multiNextStates(StateMovement... stateMovements)
      Parameters:
      stateMovements - required
      Returns:
      state decision
    • multiNextStates

      public static StateDecision multiNextStates(String... stateIds)
      use the other one with WorkflowState class param if the stateId is provided by default, to make your code cleaner or use other ones with a list of StateMovement to enable the WorkflowStateOptions overriding
      Parameters:
      stateIds - stateIds of next states
      Returns:
      state decision
    • multiNextStates

      public static StateDecision multiNextStates(Class<? extends WorkflowState>... states)
      use other ones with a list of StateMovement to enable the WorkflowStateOptions overriding
      Parameters:
      states - required
      Returns:
      state decision