Record Class UserDto

java.lang.Object
java.lang.Record
com.app.controller.dto.user.UserDto
Record Components:
id - the unique identifier of the user
name - the user's given name
surname - the user's surname
username - the user's login username
email - the user's email address
age - the user's age
holidaysHours - the number of holiday hours the user has accrued
role - the role assigned to the user (e.g., admin, worker)

public record UserDto(Long id, String name, String surname, String username, String email, Integer age, Long holidaysHours, Role role) extends Record
Data Transfer Object (DTO) representing user details. Typically used to transfer user information between layers or to the client.
  • Constructor Details

    • UserDto

      public UserDto(Long id, String name, String surname, String username, String email, Integer age, Long holidaysHours, Role role)
      Creates an instance of a UserDto record class.
      Parameters:
      id - the value for the id 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
      email - the value for the email record component
      age - the value for the age record component
      holidaysHours - the value for the holidaysHours record component
      role - the value for the role record component
  • Method Details

    • 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.
    • id

      public Long id()
      Returns the value of the id record component.
      Returns:
      the value of the id 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
    • email

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

      public Integer age()
      Returns the value of the age record component.
      Returns:
      the value of the age record component
    • holidaysHours

      public Long holidaysHours()
      Returns the value of the holidaysHours record component.
      Returns:
      the value of the holidaysHours record component
    • role

      public Role role()
      Returns the value of the role record component.
      Returns:
      the value of the role record component