Package com.tnsai.agents.groups
Record Class GroupTask
java.lang.Object
java.lang.Record
com.tnsai.agents.groups.GroupTask
- Record Components:
id- unique task IDname- task namedescription- task descriptionpriority- task prioritytimeout- maximum execution timerequiredCapabilities- capabilities needed to executeparameters- task input parametersstatus- current execution statusassigneeId- assigned agent ID (null if unassigned)createdAt- creation timestampstartedAt- execution start timecompletedAt- completion timeresult- task result (if completed)
public record GroupTask(String id, String name, String description, GroupTask.Priority priority, Duration timeout, List<String> requiredCapabilities, Map<String,Object> parameters, GroupTask.Status status, String assigneeId, Instant createdAt, Instant startedAt, Instant completedAt, Object result)
extends Record
A task to be executed by group members.
GroupTask represents work that can be assigned to agents within a group. Tasks have priorities, timeouts, required capabilities, and can track execution status.
Usage Example
GroupTask task = GroupTask.builder()
.name("Analyze Document")
.description("Extract key insights from the report")
.priority(Priority.HIGH)
.timeout(Duration.ofMinutes(5))
.requiredCapabilities(List.of("nlp", "summarization"))
.build();
Optional<Agent> assignee = group.assignTask(task);
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classBuilder for GroupTask.static enumTask priority levels.static enumTask execution status. -
Constructor Summary
ConstructorsConstructorDescriptionGroupTask(String id, String name, String description, GroupTask.Priority priority, Duration timeout, List<String> requiredCapabilities, Map<String, Object> parameters, GroupTask.Status status, String assigneeId, Instant createdAt, Instant startedAt, Instant completedAt, Object result) Creates a GroupTask with validation. -
Method Summary
Modifier and TypeMethodDescriptionReturns the value of theassigneeIdrecord component.static GroupTask.Builderbuilder()Creates a new builder.Returns the value of thecompletedAtrecord component.Returns the value of thecreatedAtrecord component.Returns the value of thedescriptionrecord component.final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.booleanChecks if task requires specific capabilities.id()Returns the value of theidrecord component.booleanChecks if task is assigned.booleanChecks if task is in a terminal state.name()Returns the value of thenamerecord component.static GroupTaskCreates a simple task with just a name.static GroupTaskCreates a task with name and description.Returns the value of theparametersrecord component.priority()Returns the value of thepriorityrecord component.Returns the value of therequiredCapabilitiesrecord component.result()Returns the value of theresultrecord component.Returns the value of thestartedAtrecord component.status()Returns the value of thestatusrecord component.timeout()Returns the value of thetimeoutrecord component.final StringtoString()Returns a string representation of this record class.withAssignee(String agentId) Creates a copy with assignee.withResult(Object taskResult) Creates a copy with result.withStatus(GroupTask.Status newStatus) Creates a copy with new status.
-
Constructor Details
-
GroupTask
public GroupTask(String id, String name, String description, GroupTask.Priority priority, Duration timeout, List<String> requiredCapabilities, Map<String, Object> parameters, GroupTask.Status status, String assigneeId, Instant createdAt, Instant startedAt, Instant completedAt, Object result) Creates a GroupTask with validation.
-
-
Method Details
-
isTerminal
public boolean isTerminal()Checks if task is in a terminal state.- Returns:
- true if terminal
-
isAssigned
public boolean isAssigned()Checks if task is assigned.- Returns:
- true if assigned
-
hasRequirements
public boolean hasRequirements()Checks if task requires specific capabilities.- Returns:
- true if capabilities required
-
withStatus
Creates a copy with new status.- Parameters:
newStatus- new status- Returns:
- updated task
-
withAssignee
Creates a copy with assignee.- Parameters:
agentId- assigned agent ID- Returns:
- updated task
-
withResult
Creates a copy with result.- Parameters:
taskResult- task result- Returns:
- updated task
-
builder
Creates a new builder.- Returns:
- builder
-
of
Creates a simple task with just a name.- Parameters:
name- task name- Returns:
- task
-
of
Creates a task with name and description.- Parameters:
name- task namedescription- task description- Returns:
- task
-
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). -
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
-
description
Returns the value of thedescriptionrecord component.- Returns:
- the value of the
descriptionrecord component
-
priority
Returns the value of thepriorityrecord component.- Returns:
- the value of the
priorityrecord component
-
timeout
Returns the value of thetimeoutrecord component.- Returns:
- the value of the
timeoutrecord component
-
requiredCapabilities
Returns the value of therequiredCapabilitiesrecord component.- Returns:
- the value of the
requiredCapabilitiesrecord component
-
parameters
Returns the value of theparametersrecord component.- Returns:
- the value of the
parametersrecord component
-
status
Returns the value of thestatusrecord component.- Returns:
- the value of the
statusrecord component
-
assigneeId
Returns the value of theassigneeIdrecord component.- Returns:
- the value of the
assigneeIdrecord component
-
createdAt
Returns the value of thecreatedAtrecord component.- Returns:
- the value of the
createdAtrecord component
-
startedAt
Returns the value of thestartedAtrecord component.- Returns:
- the value of the
startedAtrecord component
-
completedAt
Returns the value of thecompletedAtrecord component.- Returns:
- the value of the
completedAtrecord component
-
result
Returns the value of theresultrecord component.- Returns:
- the value of the
resultrecord component
-