Class Ballot

java.lang.Object
org.episteme.social.politics.Ballot
All Implemented Interfaces:
Serializable

public final class Ballot extends Object implements Serializable
Represents a cast ballot in an election, supporting various voting methods. A ballot can capture multiple decision points (e.g., President, Governor), and for each, it supports single choices, ranked lists of preferences, or ratings. Integrated with the persistence system and uses Real for internal scores.
Since:
1.0
Version:
2.1
Author:
Silvere Martin-Michiellot, Gemini AI (Google DeepMind)
See Also:
  • Constructor Details

  • Method Details

    • singleChoice

      public static Ballot singleChoice(String voterId, String electionId, String choice)
      Creates a simple single-choice ballot for a specific election.
      Parameters:
      voterId - Identifier of the voter
      electionId - The decision point ID (e.g., "PRESIDENT_2026")
      choice - The selected candidate or choice
      Returns:
      A new Ballot instance
    • rankedChoice

      public static Ballot rankedChoice(String voterId, String electionId, List<String> rankings)
      Creates a ranked-choice ballot for a specific election.
      Parameters:
      voterId - Identifier of the voter
      electionId - The decision point ID
      rankings - Ordered list of candidates (index 0 is top preference)
      Returns:
      A new Ballot instance
    • ratedChoice

      public static Ballot ratedChoice(String voterId, String electionId, Map<String,Double> scores)
      Creates a cardinal/rating ballot for a specific election from double values.
      Parameters:
      voterId - Identifier of the voter
      electionId - The decision point ID
      scores - Map of Candidate -> Score (double)
      Returns:
      A new Ballot instance
    • voterId

      public String voterId()
    • selections

      public Map<String, List<String>> selections()
    • ratings

      public Map<String, Map<String,Real>> ratings()
    • getTopChoice

      public String getTopChoice(String electionId)
      Retrieves the top choice for a given election.
      Parameters:
      electionId - the ID of the election
      Returns:
      the top candidate name, or null if none
    • toString

      public String toString()
      Overrides:
      toString in class Object