Record Class SwarmResult
java.lang.Object
java.lang.Record
com.tnsai.coordination.groups.swarm.SwarmResult
- Record Components:
taskId- task identifiersuccess- whether operation succeededoutput- final collective outputbehavior- behavior usedintelligence- intelligence algorithm usedcontributions- individual agent contributionsiterations- number of algorithm iterationsquality- solution quality (0.0 to 1.0)startedAt- start timecompletedAt- completion timemetadata- additional metadata
public record SwarmResult(String taskId, boolean success, String output, SwarmBehavior behavior, String intelligence, List<SwarmResult.AgentContribution> contributions, int iterations, double quality, Instant startedAt, Instant completedAt, Map<String,Object> metadata)
extends Record
Result of a swarm operation (explore or solve).
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final recordIndividual agent's contribution to the swarm task. -
Constructor Summary
ConstructorsConstructorDescriptionSwarmResult(String taskId, boolean success, String output, SwarmBehavior behavior, String intelligence, List<SwarmResult.AgentContribution> contributions, int iterations, double quality, Instant startedAt, Instant completedAt, Map<String, Object> metadata) Creates an instance of aSwarmResultrecord class. -
Method Summary
Modifier and TypeMethodDescriptionbehavior()Returns the value of thebehaviorrecord component.Returns the value of thecompletedAtrecord component.Returns the value of thecontributionsrecord component.final booleanIndicates whether some other object is "equal to" this one.static SwarmResultfailure(String taskId, String error, SwarmBehavior behavior, Instant startedAt) Creates a failed result.intGets contribution count.Gets execution duration.getError()Gets error message if failed.longGets successful contribution count.final inthashCode()Returns a hash code value for this object.Returns the value of theintelligencerecord component.intReturns the value of theiterationsrecord component.metadata()Returns the value of themetadatarecord component.output()Returns the value of theoutputrecord component.doublequality()Returns the value of thequalityrecord component.Returns the value of thestartedAtrecord component.booleansuccess()Returns the value of thesuccessrecord component.static SwarmResultsuccess(String taskId, String output, SwarmBehavior behavior, String intelligence, List<SwarmResult.AgentContribution> contributions, int iterations, double quality, Instant startedAt) Creates a successful result.taskId()Returns the value of thetaskIdrecord component.final StringtoString()Returns a string representation of this record class.
-
Constructor Details
-
SwarmResult
public SwarmResult(String taskId, boolean success, String output, SwarmBehavior behavior, String intelligence, List<SwarmResult.AgentContribution> contributions, int iterations, double quality, Instant startedAt, Instant completedAt, Map<String, Object> metadata) Creates an instance of aSwarmResultrecord class.- Parameters:
taskId- the value for thetaskIdrecord componentsuccess- the value for thesuccessrecord componentoutput- the value for theoutputrecord componentbehavior- the value for thebehaviorrecord componentintelligence- the value for theintelligencerecord componentcontributions- the value for thecontributionsrecord componentiterations- the value for theiterationsrecord componentquality- the value for thequalityrecord componentstartedAt- the value for thestartedAtrecord componentcompletedAt- the value for thecompletedAtrecord componentmetadata- the value for themetadatarecord component
-
-
Method Details
-
success
public static SwarmResult success(String taskId, String output, SwarmBehavior behavior, String intelligence, List<SwarmResult.AgentContribution> contributions, int iterations, double quality, Instant startedAt) Creates a successful result.- Parameters:
taskId- task IDoutput- collective outputbehavior- behavior usedintelligence- intelligence namecontributions- agent contributionsiterations- iteration countquality- solution qualitystartedAt- start time- Returns:
- success result
-
failure
public static SwarmResult failure(String taskId, String error, SwarmBehavior behavior, Instant startedAt) Creates a failed result.- Parameters:
taskId- task IDerror- error messagebehavior- behavior usedstartedAt- start time- Returns:
- failure result
-
getDuration
Gets execution duration.- Returns:
- duration
-
getContributorCount
public int getContributorCount()Gets contribution count.- Returns:
- number of contributors
-
getSuccessfulContributors
public long getSuccessfulContributors()Gets successful contribution count.- Returns:
- number of successful contributors
-
getError
Gets error message if failed.- Returns:
- error or null
-
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 '=='. -
taskId
Returns the value of thetaskIdrecord component.- Returns:
- the value of the
taskIdrecord component
-
success
public boolean success()Returns the value of thesuccessrecord component.- Returns:
- the value of the
successrecord component
-
output
Returns the value of theoutputrecord component.- Returns:
- the value of the
outputrecord component
-
behavior
Returns the value of thebehaviorrecord component.- Returns:
- the value of the
behaviorrecord component
-
intelligence
Returns the value of theintelligencerecord component.- Returns:
- the value of the
intelligencerecord component
-
contributions
Returns the value of thecontributionsrecord component.- Returns:
- the value of the
contributionsrecord component
-
iterations
public int iterations()Returns the value of theiterationsrecord component.- Returns:
- the value of the
iterationsrecord component
-
quality
public double quality()Returns the value of thequalityrecord component.- Returns:
- the value of the
qualityrecord 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
-
metadata
Returns the value of themetadatarecord component.- Returns:
- the value of the
metadatarecord component
-