Record Class NegotiationOutcome
java.lang.Object
java.lang.Record
com.tnsai.coordination.negotiation.NegotiationOutcome
- Record Components:
agreed- whether the negotiation reached agreementacceptedOffer- the accepted offer (null if no agreement)allOffers- all offers made during negotiationroundsUsed- number of rounds conducteddurationMs- total negotiation duration in millisecondsfinalState- final negotiation statefailureReason- reason for failure (null if agreed)
public record NegotiationOutcome(boolean agreed, NegotiationOffer acceptedOffer, List<NegotiationOffer> allOffers, int roundsUsed, long durationMs, NegotiationState finalState, String failureReason)
extends Record
The result of a completed negotiation.
- Since:
- 0.0.2
-
Constructor Summary
ConstructorsConstructorDescriptionNegotiationOutcome(boolean agreed, NegotiationOffer acceptedOffer, List<NegotiationOffer> allOffers, int roundsUsed, long durationMs, NegotiationState finalState, String failureReason) Creates an instance of aNegotiationOutcomerecord class. -
Method Summary
Modifier and TypeMethodDescriptionReturns the value of theacceptedOfferrecord component.booleanagreed()Returns the value of theagreedrecord component.Returns the value of theallOffersrecord component.longReturns the value of thedurationMsrecord component.final booleanIndicates whether some other object is "equal to" this one.static NegotiationOutcomefailure(String reason, List<NegotiationOffer> allOffers, int rounds, long durationMs, NegotiationState state) Creates a failed outcome.Returns the value of thefailureReasonrecord component.Returns the value of thefinalStaterecord component.final inthashCode()Returns a hash code value for this object.intReturns the value of theroundsUsedrecord component.static NegotiationOutcomesuccess(NegotiationOffer accepted, List<NegotiationOffer> allOffers, int rounds, long durationMs) Creates a successful outcome.final StringtoString()Returns a string representation of this record class.
-
Constructor Details
-
NegotiationOutcome
public NegotiationOutcome(boolean agreed, NegotiationOffer acceptedOffer, List<NegotiationOffer> allOffers, int roundsUsed, long durationMs, NegotiationState finalState, String failureReason) Creates an instance of aNegotiationOutcomerecord class.- Parameters:
agreed- the value for theagreedrecord componentacceptedOffer- the value for theacceptedOfferrecord componentallOffers- the value for theallOffersrecord componentroundsUsed- the value for theroundsUsedrecord componentdurationMs- the value for thedurationMsrecord componentfinalState- the value for thefinalStaterecord componentfailureReason- the value for thefailureReasonrecord component
-
-
Method Details
-
success
public static NegotiationOutcome success(NegotiationOffer accepted, List<NegotiationOffer> allOffers, int rounds, long durationMs) Creates a successful outcome. -
failure
public static NegotiationOutcome failure(String reason, List<NegotiationOffer> allOffers, int rounds, long durationMs, NegotiationState state) Creates a failed outcome. -
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 '=='. -
agreed
public boolean agreed()Returns the value of theagreedrecord component.- Returns:
- the value of the
agreedrecord component
-
acceptedOffer
Returns the value of theacceptedOfferrecord component.- Returns:
- the value of the
acceptedOfferrecord component
-
allOffers
Returns the value of theallOffersrecord component.- Returns:
- the value of the
allOffersrecord component
-
roundsUsed
public int roundsUsed()Returns the value of theroundsUsedrecord component.- Returns:
- the value of the
roundsUsedrecord component
-
durationMs
public long durationMs()Returns the value of thedurationMsrecord component.- Returns:
- the value of the
durationMsrecord component
-
finalState
Returns the value of thefinalStaterecord component.- Returns:
- the value of the
finalStaterecord component
-
failureReason
Returns the value of thefailureReasonrecord component.- Returns:
- the value of the
failureReasonrecord component
-