Package com.tnsai.coordination.voting
Record Class VotingResult
java.lang.Object
java.lang.Record
com.tnsai.coordination.voting.VotingResult
- Record Components:
winner- The winning option, or null if no winnervoteCounts- Number of votes per optionquorumMet- Whether the minimum number of votes was reachedunanimous- Whether all votes were for the same optionmethod- The voting method usedtotalVotes- 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 Summary
ConstructorsConstructorDescriptionVotingResult(String winner, Map<String, Integer> voteCounts, boolean quorumMet, boolean unanimous, VotingMethod method, int totalVotes) Creates an instance of aVotingResultrecord class. -
Method Summary
Modifier and TypeMethodDescriptionfinal booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.booleanReturns true if there is a winner.method()Returns the value of themethodrecord component.booleanReturns the value of thequorumMetrecord component.final StringtoString()Returns a string representation of this record class.intReturns the value of thetotalVotesrecord component.booleanReturns the value of theunanimousrecord component.Returns the value of thevoteCountsrecord component.winner()Returns the value of thewinnerrecord component.intReturns the number of votes the winner received, or 0 if no winner.
-
Constructor Details
-
VotingResult
public VotingResult(String winner, Map<String, Integer> voteCounts, boolean quorumMet, boolean unanimous, VotingMethod method, int totalVotes) Creates an instance of aVotingResultrecord class.- Parameters:
winner- the value for thewinnerrecord componentvoteCounts- the value for thevoteCountsrecord componentquorumMet- the value for thequorumMetrecord componentunanimous- the value for theunanimousrecord componentmethod- the value for themethodrecord componenttotalVotes- the value for thetotalVotesrecord 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
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 '=='. -
winner
Returns the value of thewinnerrecord component.- Returns:
- the value of the
winnerrecord component
-
voteCounts
Returns the value of thevoteCountsrecord component.- Returns:
- the value of the
voteCountsrecord component
-
quorumMet
public boolean quorumMet()Returns the value of thequorumMetrecord component.- Returns:
- the value of the
quorumMetrecord component
-
unanimous
public boolean unanimous()Returns the value of theunanimousrecord component.- Returns:
- the value of the
unanimousrecord component
-
method
Returns the value of themethodrecord component.- Returns:
- the value of the
methodrecord component
-
totalVotes
public int totalVotes()Returns the value of thetotalVotesrecord component.- Returns:
- the value of the
totalVotesrecord component
-