Class ChallengeRanking

java.lang.Object
fr.utc.miage.sporttrack.entity.event.ChallengeRanking

@Entity public class ChallengeRanking extends Object
JPA entity representing a single ranking entry within a Challenge.

Each ranking associates an athlete with a rank position and a cumulative score for the challenge's performance metric. Convenience methods are provided to obtain a display name and a formatted score string for presentation in the user interface.

Author:
SportTrack Team
  • Constructor Details

    • ChallengeRanking

      public ChallengeRanking()
  • Method Details

    • getId

      public int getId()
      Returns the unique identifier of this ranking entry.
      Returns:
      the database identifier
    • getRankPosition

      public int getRankPosition()
      Returns the rank position of the athlete in the challenge.
      Returns:
      the rank position (1-based)
    • setRankPosition

      public void setRankPosition(int rankPosition)
      Sets the rank position of the athlete.
      Parameters:
      rankPosition - the rank position to assign (1-based)
    • getScore

      public double getScore()
      Returns the cumulative score achieved by the athlete.
      Returns:
      the score value
    • setScore

      public void setScore(double score)
      Sets the cumulative score achieved by the athlete.
      Parameters:
      score - the score value to assign
    • getChallenge

      public Challenge getChallenge()
      Returns the challenge to which this ranking belongs.
      Returns:
      the parent Challenge
    • setChallenge

      public void setChallenge(Challenge challenge)
      Sets the challenge to which this ranking belongs.
      Parameters:
      challenge - the parent Challenge to assign
    • getAthlete

      public Athlete getAthlete()
      Returns the athlete associated with this ranking.
      Returns:
      the ranked Athlete
    • setAthlete

      public void setAthlete(Athlete athlete)
      Sets the athlete associated with this ranking.
      Parameters:
      athlete - the Athlete to assign
    • getDisplayName

      public String getDisplayName()
      Returns the display name of the ranked athlete. Falls back to the username or email if the full name is unavailable, and ultimately returns "Inconnu" if no athlete is associated.
      Returns:
      the athlete's display name
    • getFormattedScore

      public String getFormattedScore()
      Returns the score formatted for display in the French locale. Integer scores are shown without decimal places; non-integer scores are shown with two decimal places. Handles NaN and infinite values by returning "0".
      Returns:
      the formatted score string