Class UserDto

java.lang.Object
me.josephsf.jobportaljosephsfeir.dto.UserDto

public class UserDto extends Object
Data Transfer Object for user information.

This class encapsulates user account information in the Job Portal system, excluding sensitive information like passwords. It is primarily used for transferring user data between the service layer and the presentation layer, particularly when displaying user profiles or lists of users.

The class includes validation constraints to ensure data integrity when updating user information:

  • Username must be between 3 and 20 characters
  • Email must be valid and not exceed 50 characters

The DTO also tracks the roles assigned to the user, which determine their access levels and permissions within the system.

Since:
2025-05-14
  • Constructor Details

    • UserDto

      public UserDto()
      Default constructor for deserialization.
    • UserDto

      public UserDto(String id, String username, String email, Set<Role> roles)
      Constructs a new UserDto with essential fields.
      Parameters:
      id - The MongoDB document ID
      username - The username
      email - The email address
      roles - The set of roles assigned to the user
  • Method Details

    • getId

      public String getId()
      Gets the MongoDB document ID.
      Returns:
      The document ID
    • setId

      public void setId(String id)
      Sets the MongoDB document ID.
      Parameters:
      id - The document ID to set
    • getUsername

      public String getUsername()
      Gets the username.
      Returns:
      The username
    • setUsername

      public void setUsername(String username)
      Sets the username.
      Parameters:
      username - The username to set
    • getEmail

      public String getEmail()
      Gets the email address.
      Returns:
      The email address
    • setEmail

      public void setEmail(String email)
      Sets the email address.
      Parameters:
      email - The email address to set
    • getRoles

      public Set<Role> getRoles()
      Gets the set of roles.
      Returns:
      The set of roles
    • setRoles

      public void setRoles(Set<Role> roles)
      Sets the set of roles.
      Parameters:
      roles - The set of roles to set
    • getCreatedAt

      public LocalDateTime getCreatedAt()
      Gets the creation timestamp.
      Returns:
      The creation timestamp
    • setCreatedAt

      public void setCreatedAt(LocalDateTime createdAt)
      Sets the creation timestamp.
      Parameters:
      createdAt - The creation timestamp to set
    • getUpdatedAt

      public LocalDateTime getUpdatedAt()
      Gets the last update timestamp.
      Returns:
      The last update timestamp
    • setUpdatedAt

      public void setUpdatedAt(LocalDateTime updatedAt)
      Sets the last update timestamp.
      Parameters:
      updatedAt - The last update timestamp to set