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 propertyadmin.name
surname
- the admin's surname, injected from the propertyadmin.surname
username
- the admin's username, injected from the propertyadmin.username
password
- the admin's password, injected from the propertyadmin.password
email
- the admin's email address, injected from the propertyadmin.email
age
- the admin's age, injected from the propertyadmin.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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionint
age()
Returns the value of theage
record component.email()
Returns the value of theemail
record component.final boolean
Indicates whether some other object is "equal to" this one.final int
hashCode()
Returns a hash code value for this object.name()
Returns the value of thename
record component.password()
Returns the value of thepassword
record component.surname()
Returns the value of thesurname
record component.final String
toString()
Returns a string representation of this record class.Converts this DTO into aUserEntity
with admin privileges.username()
Returns the value of theusername
record component.
-
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 aCreateAdminUserDto
record class.- Parameters:
name
- the value for thename
record componentsurname
- the value for thesurname
record componentusername
- the value for theusername
record componentpassword
- the value for thepassword
record componentemail
- the value for theemail
record componentage
- the value for theage
record component
-
-
Method Details
-
toUserEntity
Converts this DTO into aUserEntity
with admin privileges. Sets the user's role toRole.ROLE_ADMIN
, enables the account, and initializes holiday hours to 0.- Returns:
- a new instance of
UserEntity
configured as an admin
-
toString
-
hashCode
-
equals
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 withObjects::equals(Object,Object)
; primitive components are compared with thecompare
method from their corresponding wrapper classes. -
name
-
surname
-
username
-
password
-
email
-
age
-