Record Class CoalitionResult
java.lang.Object
java.lang.Record
com.tnsai.coordination.groups.coalition.CoalitionResult
- Record Components:
coalitionId- coalition identifiergoal- the goal that was pursuedsuccess- whether goal was achievedoutput- final collective outputcontributions- member contributionsrewards- distributed rewardstotalValue- total coalition valueformation- formation strategy useddistribution- distribution strategy usedstartedAt- when attempt startedcompletedAt- when attempt completedmetadata- 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.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final recordIndividual member contribution to the coalition. -
Constructor Summary
ConstructorsConstructorDescriptionCoalitionResult(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) Creates an instance of aCoalitionResultrecord class. -
Method Summary
Modifier and TypeMethodDescriptionReturns the value of thecoalitionIdrecord component.Returns the value of thecompletedAtrecord component.Returns the value of thecontributionsrecord component.Returns the value of thedistributionrecord component.final booleanIndicates whether some other object is "equal to" this one.static CoalitionResultfailure(String coalitionId, String goal, String error, CoalitionFormation formation, Instant startedAt) Creates a failed result.Returns the value of theformationrecord component.getContributionFor(String agentId) Gets contribution for specific member.intGets number of contributors.Gets execution duration.getError()Gets error message if failed.getRewardFor(String agentId) Gets reward for specific member.longGets successful contribution count.doubleGets total contribution score.goal()Returns the value of thegoalrecord component.final inthashCode()Returns a hash code value for this object.metadata()Returns the value of themetadatarecord component.output()Returns the value of theoutputrecord component.rewards()Returns the value of therewardsrecord component.Returns the value of thestartedAtrecord component.booleansuccess()Returns the value of thesuccessrecord component.static CoalitionResultsuccess(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.final StringtoString()Returns a string representation of this record class.doubleReturns the value of thetotalValuerecord component.
-
Constructor Details
-
CoalitionResult
public 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) Creates an instance of aCoalitionResultrecord class.- Parameters:
coalitionId- the value for thecoalitionIdrecord componentgoal- the value for thegoalrecord componentsuccess- the value for thesuccessrecord componentoutput- the value for theoutputrecord componentcontributions- the value for thecontributionsrecord componentrewards- the value for therewardsrecord componenttotalValue- the value for thetotalValuerecord componentformation- the value for theformationrecord componentdistribution- the value for thedistributionrecord componentstartedAt- the value for thestartedAtrecord componentcompletedAt- the value for thecompletedAtrecord componentmetadata- the value for themetadatarecord component
-
-
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 IDgoal- achieved goaloutput- result outputcontributions- member contributionsrewards- reward distributiontotalValue- total valueformation- formation strategydistribution- distribution strategystartedAt- 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 IDgoal- attempted goalerror- error messageformation- formation strategystartedAt- start time- Returns:
- failure result
-
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
Gets reward for specific member.- Parameters:
agentId- agent ID- Returns:
- reward amount
-
getContributionFor
Gets contribution for specific member.- Parameters:
agentId- agent ID- Returns:
- contribution record
-
getError
Gets error message if failed.- Returns:
- error or null
-
getTotalContribution
public double getTotalContribution()Gets total contribution score.- Returns:
- total contribution
-
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 '=='. -
coalitionId
Returns the value of thecoalitionIdrecord component.- Returns:
- the value of the
coalitionIdrecord component
-
goal
Returns the value of thegoalrecord component.- Returns:
- the value of the
goalrecord 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
-
contributions
Returns the value of thecontributionsrecord component.- Returns:
- the value of the
contributionsrecord component
-
rewards
Returns the value of therewardsrecord component.- Returns:
- the value of the
rewardsrecord component
-
totalValue
public double totalValue()Returns the value of thetotalValuerecord component.- Returns:
- the value of the
totalValuerecord component
-
formation
Returns the value of theformationrecord component.- Returns:
- the value of the
formationrecord component
-
distribution
Returns the value of thedistributionrecord component.- Returns:
- the value of the
distributionrecord 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
-