java.lang.Object
fr.utc.miage.sporttrack.entity.user.User
All Implemented Interfaces:
Serializable
Direct Known Subclasses:
Admin, Athlete

@MappedSuperclass public abstract class User extends Object implements Serializable
Abstract base class for all user types within the SportTrack application.

This class is mapped as a JPA MappedSuperclass and provides common fields shared by both Admin and Athlete subclasses, including authentication credentials, personal information, and a dynamically generated profile photo URL.

Author:
SportTrack Team
See Also:
  • Constructor Details

    • User

      public User()
  • Method Details

    • getId

      public Integer getId()
      Returns the unique identifier of this user.
      Returns:
      the user's database identifier
    • getUsername

      public String getUsername()
      Returns the username of this user.
      Returns:
      the username
    • getPassword

      public String getPassword()
      Returns the hashed password of this user.
      Returns:
      the password hash
    • getLastName

      public String getLastName()
      Returns the last name (family name) of this user.
      Returns:
      the last name, or null if not provided
    • getFirstName

      public String getFirstName()
      Returns the first name (given name) of this user.
      Returns:
      the first name, or null if not provided
    • getEmail

      public String getEmail()
      Returns the email address of this user.
      Returns:
      the email address
    • getProfilePhotoUrl

      public String getProfilePhotoUrl()
      Generates and returns the URL of the user's profile photo. Uses the RoboHash service to produce a unique avatar based on the username. Falls back to a default avatar if the username is blank.
      Returns:
      the profile photo URL
    • setLastName

      public void setLastName(String lastName)
      Sets the last name (family name) of this user.
      Parameters:
      lastName - the last name to assign
    • setFirstName

      public void setFirstName(String firstName)
      Sets the first name (given name) of this user.
      Parameters:
      firstName - the first name to assign
    • setUsername

      public void setUsername(String username)
      Sets the username of this user.
      Parameters:
      username - the username to assign; must not be blank
      Throws:
      IllegalArgumentException - if the provided username is blank
    • setPassword

      public void setPassword(String password)
      Sets the password of this user.
      Parameters:
      password - the password to assign; must not be blank
      Throws:
      IllegalArgumentException - if the provided password is blank
    • setEmail

      public void setEmail(String email)
      Sets the email address of this user.
      Parameters:
      email - the email address to assign; must not be blank
      Throws:
      IllegalArgumentException - if the provided email is blank
    • equals

      public boolean equals(Object o)
      Compares this user to another object for equality based on the database identifier and email address.
      Overrides:
      equals in class Object
      Parameters:
      o - the object to compare with
      Returns:
      true if the objects are considered equal, false otherwise
    • hashCode

      public int hashCode()
      Returns the hash code for this user, computed from the identifier and email.
      Overrides:
      hashCode in class Object
      Returns:
      the hash code value
    • isBlank

      protected boolean isBlank(String value)
      Checks whether the given string value is blank (i.e., null, empty, or consisting solely of whitespace characters).
      Parameters:
      value - the string value to check
      Returns:
      true if the value is blank, false otherwise