Record Class CreateAdminUserDto

java.lang.Object
java.lang.Record
com.app.controller.dto.user.CreateAdminUserDto
Record Components:
name - the admin's first name, injected from the property admin.name
surname - the admin's surname, injected from the property admin.surname
username - the admin's username, injected from the property admin.username
password - the admin's password, injected from the property admin.password
email - the admin's email address, injected from the property admin.email
age - the admin's age, injected from the property admin.age

@Component public record CreateAdminUserDto(String name, String surname, String username, String password, String email, int age) extends Record
Data Transfer Object (DTO) for creating an admin user. The fields are populated from application properties using Value.

This class is also marked as a Spring Component, allowing it to be injected wherever needed.

  • Constructor Details

    • CreateAdminUserDto

      public CreateAdminUserDto(@Value("${admin.name}") String name, @Value("${admin.surname}") String surname, @Value("${admin.username}") String username, @Value("${admin.password}") String password, @Value("${admin.email}") String email, @Value("${admin.age}") int age)
      Creates an instance of a CreateAdminUserDto record class.
      Parameters:
      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

    • toUserEntity

      public UserEntity toUserEntity()
      Converts this DTO into a UserEntity with admin privileges. Sets the user's role to Role.ROLE_ADMIN, enables the account, and initializes holiday hours to 0.
      Returns:
      a new instance of UserEntity configured as an admin
    • 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.
    • name

      @Value("${admin.name}") public String name()
      Returns the value of the name record component.
      Returns:
      the value of the name record component
    • surname

      @Value("${admin.surname}") public String surname()
      Returns the value of the surname record component.
      Returns:
      the value of the surname record component
    • username

      @Value("${admin.username}") public String username()
      Returns the value of the username record component.
      Returns:
      the value of the username record component
    • password

      @Value("${admin.password}") public String password()
      Returns the value of the password record component.
      Returns:
      the value of the password record component
    • email

      @Value("${admin.email}") public String email()
      Returns the value of the email record component.
      Returns:
      the value of the email record component
    • age

      @Value("${admin.age}") public int age()
      Returns the value of the age record component.
      Returns:
      the value of the age record component