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 aProfileRequestDTOinto aProfileentity.toListResponseDTO(Collection<Profile> entities) Converts a collection ofProfileentities into a list ofProfileResponseDTO.toResponseDTO(Profile entity) Converts aProfileentity into aProfileResponseDTO.Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.alpaca.mapper.GenericMapper
toPageResponseDTO
-
Field Details
-
userService
-
-
Constructor Details
-
ProfileMapperImpl
public ProfileMapperImpl()
-
-
Method Details
-
toResponseDTO
Converts aProfileentity into aProfileResponseDTO.- Specified by:
toResponseDTOin interfaceGenericMapper<Profile,ProfileResponseDTO, ProfileRequestDTO> - Parameters:
entity- the profile entity to convert; may benull.- Returns:
- the corresponding DTO, or
nullif the input isnull.
-
toEntity
Converts aProfileRequestDTOinto aProfileentity.Retrieves the associated User using
IUserServicebased on the provided user ID string in the request DTO.- Specified by:
toEntityin interfaceGenericMapper<Profile,ProfileResponseDTO, ProfileRequestDTO> - Parameters:
requestDTO- the request DTO; may benull.- Returns:
- the constructed Profile entity, or
nullif the input isnull.
-
toListResponseDTO
Converts a collection ofProfileentities into a list ofProfileResponseDTO.- Specified by:
toListResponseDTOin interfaceGenericMapper<Profile,ProfileResponseDTO, ProfileRequestDTO> - Parameters:
entities- the collection of profile entities; may benullor empty.- Returns:
- a list of response DTOs, or an empty list if the input is null or empty.
-