Class User
java.lang.Object
me.josephsf.jobportaljosephsfeir.model.User
Model class representing a user account in the Job Portal system.
The User entity stores essential authentication and identification information for all users of the system, regardless of their role. Each user can have one or more roles (Candidate, Recruiter, or Admin) which determine their access rights.
User accounts are stored in the "users" collection in MongoDB. The username and email fields are indexed with unique constraints to ensure no duplicates.
User documents contain:
- Basic identification (username, email)
- Authentication credentials (password - stored encoded)
- Role assignments (roles)
- Audit timestamps (createdAt, updatedAt)
This class is used as the foundation for authentication and authorization throughout the application. Users with Candidate or Recruiter roles will typically have associated profile documents in the respective collections.
- Since:
- 2025-05-15
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionGets the timestamp when the user account was created.getEmail()Gets the user's email address.getId()Gets the user's unique identifier.Gets the user's password (encoded).getRoles()Gets the set of roles assigned to the user.Gets the timestamp when the user account was last updated.Gets the user's username.voidsetCreatedAt(LocalDateTime createdAt) Sets the creation timestamp for the user account.voidSets the user's email address.voidSets the user's unique identifier.voidsetPassword(String password) Sets the user's password.voidSets the roles for the user.voidsetUpdatedAt(LocalDateTime updatedAt) Sets the last update timestamp for the user account.voidsetUsername(String username) Sets the user's username.
-
Constructor Details
-
User
public User()Default constructor. Initializes creation and update timestamps to current time. -
User
Constructor with essential user details. Initializes a new user with username, email, and password.- Parameters:
username- the user's login nameemail- the user's email addresspassword- the user's password (should be encoded before passing)
-
-
Method Details
-
getId
Gets the user's unique identifier.- Returns:
- the user ID
-
setId
Sets the user's unique identifier.- Parameters:
id- the user ID to set
-
getUsername
Gets the user's username.- Returns:
- the username
-
setUsername
Sets the user's username.- Parameters:
username- the username to set
-
getEmail
Gets the user's email address.- Returns:
- the email address
-
setEmail
Sets the user's email address.- Parameters:
email- the email address to set
-
getPassword
Gets the user's password (encoded).- Returns:
- the encoded password
-
setPassword
Sets the user's password. Note: The password should be encoded before setting.- Parameters:
password- the encoded password to set
-
getRoles
Gets the set of roles assigned to the user.- Returns:
- the set of roles
-
setRoles
Sets the roles for the user.- Parameters:
roles- the set of roles to assign
-
getCreatedAt
Gets the timestamp when the user account was created.- Returns:
- the creation timestamp
-
setCreatedAt
Sets the creation timestamp for the user account.- Parameters:
createdAt- the creation timestamp to set
-
getUpdatedAt
Gets the timestamp when the user account was last updated.- Returns:
- the last update timestamp
-
setUpdatedAt
Sets the last update timestamp for the user account.- Parameters:
updatedAt- the update timestamp to set
-