Package com.tnsai.coordination.workflow
Record Class WorkflowStep
java.lang.Object
java.lang.Record
com.tnsai.coordination.workflow.WorkflowStep
- Record Components:
id- unique step identifiername- human-readable step nameagent- the agent responsible for executing this stepdependencies- IDs of steps that must complete before this onecondition- optional predicate to decide if step should executecompensation- optional compensation step for saga rollbacktimeoutMs- 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 Summary
ConstructorsConstructorDescriptionWorkflowStep(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 aWorkflowSteprecord class. -
Method Summary
Modifier and TypeMethodDescriptioncom.tnsai.agents.Agentagent()Returns the value of theagentrecord component.Returns the value of thecompensationrecord component.Returns the value of theconditionrecord component.Returns the value of thedependenciesrecord component.final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.id()Returns the value of theidrecord component.booleanisRoot()Whether this step has no dependencies.name()Returns the value of thenamerecord component.static WorkflowStepCreates a simple step with no dependencies.static WorkflowStepCreates a step with dependencies.longReturns the value of thetimeoutMsrecord component.final StringtoString()Returns a string representation of this record class.withCompensation(WorkflowStep compensationStep) Creates a step with a compensation action for saga pattern.withCondition(Predicate<WorkflowContext> predicate) Creates a conditional step.withTimeout(long ms) Creates a step with timeout.
-
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 aWorkflowSteprecord class.- Parameters:
id- the value for theidrecord componentname- the value for thenamerecord componentagent- the value for theagentrecord componentdependencies- the value for thedependenciesrecord componentcondition- the value for theconditionrecord componentcompensation- the value for thecompensationrecord componenttimeoutMs- the value for thetimeoutMsrecord component
-
-
Method Details
-
of
Creates a simple step with no dependencies. -
of
Creates a step with dependencies. -
withCompensation
Creates a step with a compensation action for saga pattern. -
withCondition
Creates a conditional step. -
withTimeout
Creates a step with timeout. -
isRoot
public boolean isRoot()Whether this step has no dependencies. -
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. -
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. -
equals
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 withObjects::equals(Object,Object); primitive components are compared with '=='. -
id
Returns the value of theidrecord component.- Returns:
- the value of the
idrecord component
-
name
Returns the value of thenamerecord component.- Returns:
- the value of the
namerecord component
-
agent
public com.tnsai.agents.Agent agent()Returns the value of theagentrecord component.- Returns:
- the value of the
agentrecord component
-
dependencies
Returns the value of thedependenciesrecord component.- Returns:
- the value of the
dependenciesrecord component
-
condition
Returns the value of theconditionrecord component.- Returns:
- the value of the
conditionrecord component
-
compensation
Returns the value of thecompensationrecord component.- Returns:
- the value of the
compensationrecord component
-
timeoutMs
public long timeoutMs()Returns the value of thetimeoutMsrecord component.- Returns:
- the value of the
timeoutMsrecord component
-