Class StateMachineFragment

java.lang.Object
software.amazon.jsii.JsiiObject
software.constructs.Construct
software.amazon.awscdk.services.stepfunctions.StateMachineFragment
All Implemented Interfaces:
IChainable, software.amazon.jsii.JsiiSerializable, software.constructs.IConstruct, software.constructs.IDependable

@Generated(value="jsii-pacmak/1.104.0 (build e79254c)", date="2024-12-11T23:26:41.927Z") @Stability(Stable) public abstract class StateMachineFragment extends software.constructs.Construct implements IChainable
Base class for reusable state machine fragments.

Example:

 import software.amazon.awscdk.Stack;
 import software.constructs.Construct;
 import software.amazon.awscdk.services.stepfunctions.*;
 public class MyJobProps {
     private String jobFlavor;
     public String getJobFlavor() {
         return this.jobFlavor;
     }
     public MyJobProps jobFlavor(String jobFlavor) {
         this.jobFlavor = jobFlavor;
         return this;
     }
 }
 public class MyJob extends StateMachineFragment {
     public final State startState;
     public final INextable[] endStates;
     public MyJob(Construct parent, String id, MyJobProps props) {
         super(parent, id);
         Choice choice = new Choice(this, "Choice").when(Condition.stringEquals("$.branch", "left"), new Pass(this, "Left Branch")).when(Condition.stringEquals("$.branch", "right"), new Pass(this, "Right Branch"));
         // ...
         this.startState = choice;
         this.endStates = choice.afterwards().getEndStates();
     }
 }
 public class MyStack extends Stack {
     public MyStack(Construct scope, String id) {
         super(scope, id);
         // Do 3 different variants of MyJob in parallel
         Parallel parallel = new Parallel(this, "All jobs").branch(new MyJob(this, "Quick", new MyJobProps().jobFlavor("quick")).prefixStates()).branch(new MyJob(this, "Medium", new MyJobProps().jobFlavor("medium")).prefixStates()).branch(new MyJob(this, "Slow", new MyJobProps().jobFlavor("slow")).prefixStates());
         StateMachine.Builder.create(this, "MyStateMachine")
                 .definitionBody(DefinitionBody.fromChainable(parallel))
                 .build();
     }
 }
 
  • Nested Class Summary

    Nested classes/interfaces inherited from class software.amazon.jsii.JsiiObject

    software.amazon.jsii.JsiiObject.InitializationMode

    Nested classes/interfaces inherited from interface software.amazon.awscdk.services.stepfunctions.IChainable

    IChainable.Jsii$Default

    Nested classes/interfaces inherited from interface software.constructs.IConstruct

    software.constructs.IConstruct.Jsii$Default
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
    StateMachineFragment(software.amazon.jsii.JsiiObject.InitializationMode initializationMode)
     
    protected
    StateMachineFragment(software.amazon.jsii.JsiiObjectRef objRef)
     
    protected
    StateMachineFragment(software.constructs.Construct scope, String id)
    Creates a new construct node.
  • Method Summary

    Modifier and Type
    Method
    Description
    abstract List<INextable>
    The states to chain onto if this fragment is used.
    Descriptive identifier for this chainable.
    abstract State
    The start state of this state machine fragment.
    Continue normal execution with the given state.
    Prefix the IDs of all states in this state machine fragment.
    Prefix the IDs of all states in this state machine fragment.
    Wrap all states in this state machine fragment up into a single state.
    Wrap all states in this state machine fragment up into a single state.

    Methods inherited from class software.constructs.Construct

    getNode, isConstruct, toString

    Methods inherited from class software.amazon.jsii.JsiiObject

    jsiiAsyncCall, jsiiAsyncCall, jsiiCall, jsiiCall, jsiiGet, jsiiGet, jsiiSet, jsiiStaticCall, jsiiStaticCall, jsiiStaticGet, jsiiStaticGet, jsiiStaticSet, jsiiStaticSet

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait

    Methods inherited from interface software.amazon.jsii.JsiiSerializable

    $jsii$toJson
  • Constructor Details

    • StateMachineFragment

      protected StateMachineFragment(software.amazon.jsii.JsiiObjectRef objRef)
    • StateMachineFragment

      protected StateMachineFragment(software.amazon.jsii.JsiiObject.InitializationMode initializationMode)
    • StateMachineFragment

      @Stability(Stable) protected StateMachineFragment(@NotNull software.constructs.Construct scope, @NotNull String id)
      Creates a new construct node.

      Parameters:
      scope - The scope in which to define this construct. This parameter is required.
      id - The scoped construct ID. This parameter is required.
  • Method Details

    • next

      @Stability(Stable) @NotNull public Chain next(@NotNull IChainable next)
      Continue normal execution with the given state.

      Parameters:
      next - This parameter is required.
    • prefixStates

      @Stability(Stable) @NotNull public StateMachineFragment prefixStates(@Nullable String prefix)
      Prefix the IDs of all states in this state machine fragment.

      Use this to avoid multiple copies of the state machine all having the same state IDs.

      Parameters:
      prefix - The prefix to add.
    • prefixStates

      @Stability(Stable) @NotNull public StateMachineFragment prefixStates()
      Prefix the IDs of all states in this state machine fragment.

      Use this to avoid multiple copies of the state machine all having the same state IDs.

    • toSingleState

      @Stability(Stable) @NotNull public Parallel toSingleState(@Nullable SingleStateOptions options)
      Wrap all states in this state machine fragment up into a single state.

      This can be used to add retry or error handling onto this state machine fragment.

      Be aware that this changes the result of the inner state machine to be an array with the result of the state machine in it. Adjust your paths accordingly. For example, change 'outputPath' to '$[0]'.

      Parameters:
      options -
    • toSingleState

      @Stability(Stable) @NotNull public Parallel toSingleState()
      Wrap all states in this state machine fragment up into a single state.

      This can be used to add retry or error handling onto this state machine fragment.

      Be aware that this changes the result of the inner state machine to be an array with the result of the state machine in it. Adjust your paths accordingly. For example, change 'outputPath' to '$[0]'.

    • getEndStates

      @Stability(Stable) @NotNull public abstract List<INextable> getEndStates()
      The states to chain onto if this fragment is used.
      Specified by:
      getEndStates in interface IChainable
    • getId

      @Stability(Stable) @NotNull public String getId()
      Descriptive identifier for this chainable.
      Specified by:
      getId in interface IChainable
    • getStartState

      @Stability(Stable) @NotNull public abstract State getStartState()
      The start state of this state machine fragment.
      Specified by:
      getStartState in interface IChainable