Record Class WorkflowStep

java.lang.Object
java.lang.Record
com.tnsai.coordination.workflow.WorkflowStep
Record Components:
id - unique step identifier
name - human-readable step name
agent - the agent responsible for executing this step
dependencies - IDs of steps that must complete before this one
condition - optional predicate to decide if step should execute
compensation - optional compensation step for saga rollback
timeoutMs - maximum execution time in milliseconds (0 = no timeout)

public record WorkflowStep(String id, String name, com.tnsai.agents.Agent agent, List<String> dependencies, Optional<Predicate<WorkflowContext>> condition, Optional<WorkflowStep> compensation, long timeoutMs) extends Record
A single step in a workflow execution plan. Steps can be sequential, parallel, or conditional.
  • Constructor Details

    • WorkflowStep

      public WorkflowStep(String id, String name, com.tnsai.agents.Agent agent, List<String> dependencies, Optional<Predicate<WorkflowContext>> condition, Optional<WorkflowStep> compensation, long timeoutMs)
      Creates an instance of a WorkflowStep record class.
      Parameters:
      id - the value for the id record component
      name - the value for the name record component
      agent - the value for the agent record component
      dependencies - the value for the dependencies record component
      condition - the value for the condition record component
      compensation - the value for the compensation record component
      timeoutMs - the value for the timeoutMs record component
  • Method Details

    • of

      public static WorkflowStep of(String id, com.tnsai.agents.Agent agent)
      Creates a simple step with no dependencies.
    • of

      public static WorkflowStep of(String id, com.tnsai.agents.Agent agent, List<String> dependencies)
      Creates a step with dependencies.
    • withCompensation

      public WorkflowStep withCompensation(WorkflowStep compensationStep)
      Creates a step with a compensation action for saga pattern.
    • withCondition

      public WorkflowStep withCondition(Predicate<WorkflowContext> predicate)
      Creates a conditional step.
    • withTimeout

      public WorkflowStep withTimeout(long ms)
      Creates a step with timeout.
    • isRoot

      public boolean isRoot()
      Whether this step has no dependencies.
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared with Objects::equals(Object,Object); primitive components are compared with '=='.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • id

      public String id()
      Returns the value of the id record component.
      Returns:
      the value of the id record component
    • name

      public String name()
      Returns the value of the name record component.
      Returns:
      the value of the name record component
    • agent

      public com.tnsai.agents.Agent agent()
      Returns the value of the agent record component.
      Returns:
      the value of the agent record component
    • dependencies

      public List<String> dependencies()
      Returns the value of the dependencies record component.
      Returns:
      the value of the dependencies record component
    • condition

      public Optional<Predicate<WorkflowContext>> condition()
      Returns the value of the condition record component.
      Returns:
      the value of the condition record component
    • compensation

      public Optional<WorkflowStep> compensation()
      Returns the value of the compensation record component.
      Returns:
      the value of the compensation record component
    • timeoutMs

      public long timeoutMs()
      Returns the value of the timeoutMs record component.
      Returns:
      the value of the timeoutMs record component