Record Class CoalitionResult

java.lang.Object
java.lang.Record
com.tnsai.coordination.groups.coalition.CoalitionResult
Record Components:
coalitionId - coalition identifier
goal - the goal that was pursued
success - whether goal was achieved
output - final collective output
contributions - member contributions
rewards - distributed rewards
totalValue - total coalition value
formation - formation strategy used
distribution - distribution strategy used
startedAt - when attempt started
completedAt - when attempt completed
metadata - additional metadata

public record CoalitionResult(String coalitionId, String goal, boolean success, String output, List<CoalitionResult.MemberContribution> contributions, Map<String,Double> rewards, double totalValue, CoalitionFormation formation, RewardDistribution distribution, Instant startedAt, Instant completedAt, Map<String,Object> metadata) extends Record
Result of a coalition goal achievement attempt.
  • Constructor Details

  • Method Details

    • success

      public static CoalitionResult success(String coalitionId, String goal, String output, List<CoalitionResult.MemberContribution> contributions, Map<String,Double> rewards, double totalValue, CoalitionFormation formation, RewardDistribution distribution, Instant startedAt)
      Creates a successful result.
      Parameters:
      coalitionId - coalition ID
      goal - achieved goal
      output - result output
      contributions - member contributions
      rewards - reward distribution
      totalValue - total value
      formation - formation strategy
      distribution - distribution strategy
      startedAt - start time
      Returns:
      success result
    • failure

      public static CoalitionResult failure(String coalitionId, String goal, String error, CoalitionFormation formation, Instant startedAt)
      Creates a failed result.
      Parameters:
      coalitionId - coalition ID
      goal - attempted goal
      error - error message
      formation - formation strategy
      startedAt - start time
      Returns:
      failure result
    • getDuration

      public Duration getDuration()
      Gets execution duration.
      Returns:
      duration
    • getContributorCount

      public int getContributorCount()
      Gets number of contributors.
      Returns:
      contributor count
    • getSuccessfulContributions

      public long getSuccessfulContributions()
      Gets successful contribution count.
      Returns:
      success count
    • getRewardFor

      public Optional<Double> getRewardFor(String agentId)
      Gets reward for specific member.
      Parameters:
      agentId - agent ID
      Returns:
      reward amount
    • getContributionFor

      public Optional<CoalitionResult.MemberContribution> getContributionFor(String agentId)
      Gets contribution for specific member.
      Parameters:
      agentId - agent ID
      Returns:
      contribution record
    • getError

      public String getError()
      Gets error message if failed.
      Returns:
      error or null
    • getTotalContribution

      public double getTotalContribution()
      Gets total contribution score.
      Returns:
      total contribution
    • 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.
    • coalitionId

      public String coalitionId()
      Returns the value of the coalitionId record component.
      Returns:
      the value of the coalitionId record component
    • goal

      public String goal()
      Returns the value of the goal record component.
      Returns:
      the value of the goal 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
    • contributions

      public List<CoalitionResult.MemberContribution> contributions()
      Returns the value of the contributions record component.
      Returns:
      the value of the contributions record component
    • rewards

      public Map<String,Double> rewards()
      Returns the value of the rewards record component.
      Returns:
      the value of the rewards record component
    • totalValue

      public double totalValue()
      Returns the value of the totalValue record component.
      Returns:
      the value of the totalValue record component
    • formation

      public CoalitionFormation formation()
      Returns the value of the formation record component.
      Returns:
      the value of the formation record component
    • distribution

      public RewardDistribution distribution()
      Returns the value of the distribution record component.
      Returns:
      the value of the distribution 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