Record Class VotingResult

java.lang.Object
java.lang.Record
com.tnsai.coordination.voting.VotingResult
Record Components:
winner - The winning option, or null if no winner
voteCounts - Number of votes per option
quorumMet - Whether the minimum number of votes was reached
unanimous - Whether all votes were for the same option
method - The voting method used
totalVotes - Total number of votes cast

public record VotingResult(String winner, Map<String,Integer> voteCounts, boolean quorumMet, boolean unanimous, VotingMethod method, int totalVotes) extends Record
Result of a completed voting session.
  • Constructor Details

    • VotingResult

      public VotingResult(String winner, Map<String,Integer> voteCounts, boolean quorumMet, boolean unanimous, VotingMethod method, int totalVotes)
      Creates an instance of a VotingResult record class.
      Parameters:
      winner - the value for the winner record component
      voteCounts - the value for the voteCounts record component
      quorumMet - the value for the quorumMet record component
      unanimous - the value for the unanimous record component
      method - the value for the method record component
      totalVotes - the value for the totalVotes record component
  • Method Details

    • hasWinner

      public boolean hasWinner()
      Returns true if there is a winner.
    • winnerVotes

      public int winnerVotes()
      Returns the number of votes the winner received, or 0 if no winner.
    • 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.
    • winner

      public String winner()
      Returns the value of the winner record component.
      Returns:
      the value of the winner record component
    • voteCounts

      public Map<String,Integer> voteCounts()
      Returns the value of the voteCounts record component.
      Returns:
      the value of the voteCounts record component
    • quorumMet

      public boolean quorumMet()
      Returns the value of the quorumMet record component.
      Returns:
      the value of the quorumMet record component
    • unanimous

      public boolean unanimous()
      Returns the value of the unanimous record component.
      Returns:
      the value of the unanimous record component
    • method

      public VotingMethod method()
      Returns the value of the method record component.
      Returns:
      the value of the method record component
    • totalVotes

      public int totalVotes()
      Returns the value of the totalVotes record component.
      Returns:
      the value of the totalVotes record component