Record Class NegotiationOutcome

java.lang.Object
java.lang.Record
com.tnsai.coordination.negotiation.NegotiationOutcome
Record Components:
agreed - whether the negotiation reached agreement
acceptedOffer - the accepted offer (null if no agreement)
allOffers - all offers made during negotiation
roundsUsed - number of rounds conducted
durationMs - total negotiation duration in milliseconds
finalState - final negotiation state
failureReason - 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 Details

    • NegotiationOutcome

      public NegotiationOutcome(boolean agreed, NegotiationOffer acceptedOffer, List<NegotiationOffer> allOffers, int roundsUsed, long durationMs, NegotiationState finalState, String failureReason)
      Creates an instance of a NegotiationOutcome record class.
      Parameters:
      agreed - the value for the agreed record component
      acceptedOffer - the value for the acceptedOffer record component
      allOffers - the value for the allOffers record component
      roundsUsed - the value for the roundsUsed record component
      durationMs - the value for the durationMs record component
      finalState - the value for the finalState record component
      failureReason - the value for the failureReason record 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

      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.
    • agreed

      public boolean agreed()
      Returns the value of the agreed record component.
      Returns:
      the value of the agreed record component
    • acceptedOffer

      public NegotiationOffer acceptedOffer()
      Returns the value of the acceptedOffer record component.
      Returns:
      the value of the acceptedOffer record component
    • allOffers

      public List<NegotiationOffer> allOffers()
      Returns the value of the allOffers record component.
      Returns:
      the value of the allOffers record component
    • roundsUsed

      public int roundsUsed()
      Returns the value of the roundsUsed record component.
      Returns:
      the value of the roundsUsed record component
    • durationMs

      public long durationMs()
      Returns the value of the durationMs record component.
      Returns:
      the value of the durationMs record component
    • finalState

      public NegotiationState finalState()
      Returns the value of the finalState record component.
      Returns:
      the value of the finalState record component
    • failureReason

      public String failureReason()
      Returns the value of the failureReason record component.
      Returns:
      the value of the failureReason record component