Record Class SwarmResult

java.lang.Object
java.lang.Record
com.tnsai.coordination.groups.swarm.SwarmResult
Record Components:
taskId - task identifier
success - whether operation succeeded
output - final collective output
behavior - behavior used
intelligence - intelligence algorithm used
contributions - individual agent contributions
iterations - number of algorithm iterations
quality - solution quality (0.0 to 1.0)
startedAt - start time
completedAt - completion time
metadata - 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).
  • 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 a SwarmResult record class.
      Parameters:
      taskId - the value for the taskId record component
      success - the value for the success record component
      output - the value for the output record component
      behavior - the value for the behavior record component
      intelligence - the value for the intelligence record component
      contributions - the value for the contributions record component
      iterations - the value for the iterations record component
      quality - the value for the quality record component
      startedAt - the value for the startedAt record component
      completedAt - the value for the completedAt record component
      metadata - the value for the metadata record 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 ID
      output - collective output
      behavior - behavior used
      intelligence - intelligence name
      contributions - agent contributions
      iterations - iteration count
      quality - solution quality
      startedAt - 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 ID
      error - error message
      behavior - behavior used
      startedAt - start time
      Returns:
      failure result
    • getDuration

      public Duration 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

      public String getError()
      Gets error message if failed.
      Returns:
      error or null
    • 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.
    • taskId

      public String taskId()
      Returns the value of the taskId record component.
      Returns:
      the value of the taskId record component
    • success

      public boolean success()
      Returns the value of the success record component.
      Returns:
      the value of the success record component
    • output

      public String output()
      Returns the value of the output record component.
      Returns:
      the value of the output record component
    • behavior

      public SwarmBehavior behavior()
      Returns the value of the behavior record component.
      Returns:
      the value of the behavior record component
    • intelligence

      public String intelligence()
      Returns the value of the intelligence record component.
      Returns:
      the value of the intelligence record component
    • contributions

      public List<SwarmResult.AgentContribution> contributions()
      Returns the value of the contributions record component.
      Returns:
      the value of the contributions record component
    • iterations

      public int iterations()
      Returns the value of the iterations record component.
      Returns:
      the value of the iterations record component
    • quality

      public double quality()
      Returns the value of the quality record component.
      Returns:
      the value of the quality record component
    • startedAt

      public Instant startedAt()
      Returns the value of the startedAt record component.
      Returns:
      the value of the startedAt record component
    • completedAt

      public Instant completedAt()
      Returns the value of the completedAt record component.
      Returns:
      the value of the completedAt record component
    • metadata

      public Map<String,Object> metadata()
      Returns the value of the metadata record component.
      Returns:
      the value of the metadata record component