Class User
java.lang.Object
fr.utc.miage.sporttrack.entity.user.User
- All Implemented Interfaces:
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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanCompares this user to another object for equality based on the database identifier and email address.getEmail()Returns the email address of this user.Returns the first name (given name) of this user.getId()Returns the unique identifier of this user.Returns the last name (family name) of this user.Returns the hashed password of this user.Generates and returns the URL of the user's profile photo.Returns the username of this user.inthashCode()Returns the hash code for this user, computed from the identifier and email.protected booleanChecks whether the given string value is blank (i.e.,null, empty, or consisting solely of whitespace characters).voidSets the email address of this user.voidsetFirstName(String firstName) Sets the first name (given name) of this user.voidsetLastName(String lastName) Sets the last name (family name) of this user.voidsetPassword(String password) Sets the password of this user.voidsetUsername(String username) Sets the username of this user.
-
Constructor Details
-
User
public User()
-
-
Method Details
-
getId
Returns the unique identifier of this user.- Returns:
- the user's database identifier
-
getUsername
Returns the username of this user.- Returns:
- the username
-
getPassword
Returns the hashed password of this user.- Returns:
- the password hash
-
getLastName
Returns the last name (family name) of this user.- Returns:
- the last name, or
nullif not provided
-
getFirstName
Returns the first name (given name) of this user.- Returns:
- the first name, or
nullif not provided
-
getEmail
Returns the email address of this user.- Returns:
- the email address
-
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
Sets the last name (family name) of this user.- Parameters:
lastName- the last name to assign
-
setFirstName
Sets the first name (given name) of this user.- Parameters:
firstName- the first name to assign
-
setUsername
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
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
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
Compares this user to another object for equality based on the database identifier and email address. -
hashCode
public int hashCode()Returns the hash code for this user, computed from the identifier and email. -
isBlank
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:
trueif the value is blank,falseotherwise
-