Record Class CreateUserDto

java.lang.Object
java.lang.Record
dev.fernando.user_authentication_api.dto.CreateUserDto
Record Components:
username - the user's name
email - the user's email
password - the user's password
phone - the user's phone number
cpf - the user's CPF (Brazilian ID)
birthdayDate - the user's birthday date

public record CreateUserDto(String username, String email, String password, String phone, String cpf, Date birthdayDate) extends Record
Data Transfer Object for creating a new user. Contains user registration information such as username, email, password, phone, cpf, and birthday date.
  • Constructor Details

    • CreateUserDto

      public CreateUserDto(String username, String email, String password, String phone, String cpf, Date birthdayDate)
      Creates an instance of a CreateUserDto record class.
      Parameters:
      username - the value for the username record component
      email - the value for the email record component
      password - the value for the password record component
      phone - the value for the phone record component
      cpf - the value for the cpf record component
      birthdayDate - the value for the birthdayDate record component
  • Method Details

    • toUser

      public User toUser()
      Converts this CreateUserDto to a User model object.
      Returns:
      a User object populated with the data from this DTO
    • dateToEpoch

      public Long dateToEpoch(Date date)
      Converts a Date object to its epoch time representation in milliseconds for storage in the database.
      Parameters:
      date - the Date object to convert
      Returns:
      the epoch time in milliseconds, or null if the date is null
    • 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. All components in this record class are compared with Objects::equals(Object,Object).
      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.
    • username

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

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

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

      public String phone()
      Returns the value of the phone record component.
      Returns:
      the value of the phone record component
    • cpf

      public String cpf()
      Returns the value of the cpf record component.
      Returns:
      the value of the cpf record component
    • birthdayDate

      public Date birthdayDate()
      Returns the value of the birthdayDate record component.
      Returns:
      the value of the birthdayDate record component