Package com.alpaca.mapper.impl
Class ProfileMapperImpl
java.lang.Object
com.alpaca.mapper.impl.ProfileMapperImpl
- All Implemented Interfaces:
GenericMapper<Profile,
,ProfileResponseDTO, ProfileRequestDTO> IProfileMapper
Implementation of
IProfileMapper
for mapping between Profile
entities and their
corresponding request and response DTOs.
This class uses IUserService
to resolve the User entity from the given user ID in the
request DTO when constructing a Profile entity.
Responsibilities:
- Convert a Profile entity to
ProfileResponseDTO
, including nested user details. - Construct a Profile entity from
ProfileRequestDTO
, resolving the associated User. - Transform collections of Profile entities into lists of ProfileResponseDTOs.
- Handle null or empty inputs gracefully by returning null or empty collections.
This class is annotated with Component
to enable Spring's dependency injection and
uses Lombok's RequiredArgsConstructor
for constructor-based injection (if required in
future).
- See Also:
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiontoEntity
(ProfileRequestDTO requestDTO) Converts aProfileRequestDTO
into aProfile
entity.toListResponseDTO
(Collection<Profile> entities) Converts a collection ofProfile
entities into a list ofProfileResponseDTO
.toResponseDTO
(Profile entity) Converts aProfile
entity into aProfileResponseDTO
.Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.alpaca.mapper.GenericMapper
toPageResponseDTO
-
Field Details
-
userService
-
-
Constructor Details
-
ProfileMapperImpl
public ProfileMapperImpl()
-
-
Method Details
-
toResponseDTO
Converts aProfile
entity into aProfileResponseDTO
.- Specified by:
toResponseDTO
in interfaceGenericMapper<Profile,
ProfileResponseDTO, ProfileRequestDTO> - Parameters:
entity
- the profile entity to convert; may benull
.- Returns:
- the corresponding DTO, or
null
if the input isnull
.
-
toEntity
Converts aProfileRequestDTO
into aProfile
entity.Retrieves the associated User using
IUserService
based on the provided user ID string in the request DTO.- Specified by:
toEntity
in interfaceGenericMapper<Profile,
ProfileResponseDTO, ProfileRequestDTO> - Parameters:
requestDTO
- the request DTO; may benull
.- Returns:
- the constructed Profile entity, or
null
if the input isnull
.
-
toListResponseDTO
Converts a collection ofProfile
entities into a list ofProfileResponseDTO
.- Specified by:
toListResponseDTO
in interfaceGenericMapper<Profile,
ProfileResponseDTO, ProfileRequestDTO> - Parameters:
entities
- the collection of profile entities; may benull
or empty.- Returns:
- a list of response DTOs, or an empty list if the input is null or empty.
-