Record Class CreateUserDto

java.lang.Object
java.lang.Record
com.app.controller.dto.user.CreateUserDto
Record Components:
firstName - the user's first name (currently unused in mapping)
name - the user's given name (used in entity)
surname - the user's surname
username - the desired username for login
password - the user's password
email - the user's email address
age - the user's age

public record CreateUserDto(String firstName, String name, String surname, String username, String password, String email, int age) extends Record
Data Transfer Object (DTO) used to create a new regular user. Contains personal and account information needed for user registration.
  • Constructor Details

    • CreateUserDto

      public CreateUserDto(String firstName, String name, String surname, String username, String password, String email, int age)
      Creates an instance of a CreateUserDto record class.
      Parameters:
      firstName - the value for the firstName record component
      name - the value for the name record component
      surname - the value for the surname record component
      username - the value for the username record component
      password - the value for the password record component
      email - the value for the email record component
      age - the value for the age record component
  • Method Details

    • toEntity

      public UserEntity toEntity()
      Converts this DTO into a UserEntity with default settings. Sets the role to Role.ROLE_WORKER, disables the account by default, and initializes holiday hours to 0.
      Returns:
      a new UserEntity instance based on this DTO
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared with Objects::equals(Object,Object); primitive components are compared with the compare method from their corresponding wrapper classes.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • firstName

      public String firstName()
      Returns the value of the firstName record component.
      Returns:
      the value of the firstName record component
    • name

      public String name()
      Returns the value of the name record component.
      Returns:
      the value of the name record component
    • surname

      public String surname()
      Returns the value of the surname record component.
      Returns:
      the value of the surname record component
    • username

      public String username()
      Returns the value of the username record component.
      Returns:
      the value of the username record component
    • password

      public String password()
      Returns the value of the password record component.
      Returns:
      the value of the password record component
    • email

      public String email()
      Returns the value of the email record component.
      Returns:
      the value of the email record component
    • age

      public int age()
      Returns the value of the age record component.
      Returns:
      the value of the age record component