Package com.tnsai.coordination.workflow
Record Class Branch
java.lang.Object
java.lang.Record
com.tnsai.coordination.workflow.Branch
public record Branch(Predicate<WorkflowContext> condition, String targetStepId, com.tnsai.agents.Agent targetAgent)
extends Record
A conditional branch in a workflow.
Each branch has a condition predicate and a target step. When the condition evaluates to true, the target step is executed.
Usage
Branch.when(ctx -> ctx.get("valid").equals("true"))
.then("process", processAgent)
- Since:
- 0.0.5
-
Nested Class Summary
Nested Classes -
Constructor Summary
ConstructorsConstructorDescriptionBranch(Predicate<WorkflowContext> condition, String targetStepId, com.tnsai.agents.Agent targetAgent) Creates an instance of aBranchrecord class. -
Method Summary
Modifier and TypeMethodDescriptionReturns the value of theconditionrecord component.final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.static Branch.BranchBuilderCreates a default/else branch that always matches.com.tnsai.agents.AgentReturns the value of thetargetAgentrecord component.Returns the value of thetargetStepIdrecord component.final StringtoString()Returns a string representation of this record class.static Branch.BranchBuilderwhen(Predicate<WorkflowContext> condition) Creates a branch builder with a condition.
-
Constructor Details
-
Branch
public Branch(Predicate<WorkflowContext> condition, String targetStepId, com.tnsai.agents.Agent targetAgent) Creates an instance of aBranchrecord class.- Parameters:
condition- the value for theconditionrecord componenttargetStepId- the value for thetargetStepIdrecord componenttargetAgent- the value for thetargetAgentrecord component
-
-
Method Details
-
when
Creates a branch builder with a condition. -
otherwise
Creates a default/else branch that always matches. -
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. All components in this record class are compared withObjects::equals(Object,Object). -
condition
Returns the value of theconditionrecord component.- Returns:
- the value of the
conditionrecord component
-
targetStepId
Returns the value of thetargetStepIdrecord component.- Returns:
- the value of the
targetStepIdrecord component
-
targetAgent
public com.tnsai.agents.Agent targetAgent()Returns the value of thetargetAgentrecord component.- Returns:
- the value of the
targetAgentrecord component
-