Package com.alpaca.mapper.impl
Class AdvertiserMapperImpl
java.lang.Object
com.alpaca.mapper.impl.AdvertiserMapperImpl
- All Implemented Interfaces:
GenericMapper<Advertiser,,AdvertiserResponseDTO, AdvertiserRequestDTO> IAdvertiserMapper
Implementation of the
IAdvertiserMapper interface, responsible for converting between
Advertiser entities and their corresponding request and response DTOs.
This mapper relies on IUserService to resolve the associated User entity based on ID
provided in the request DTO during conversion to an Advertiser entity.
Primary responsibilities:
- Convert a
Advertiserentity into anAdvertiserResponseDTO. - Construct an
Advertiserentity from anAdvertiserRequestDTO, initializing default flags and resolving the associated User viaIUserService. - Transform collections of Advertiser entities into lists of
AdvertiserResponseDTO. - Handle null or empty inputs gracefully by returning null or empty lists respectively.
The class is annotated with Component for Spring integration, and leverages Lombok's
RequiredArgsConstructor for constructor-based dependency injection.
- See Also:
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiontoEntity(AdvertiserRequestDTO requestDTO) Converts anAdvertiserRequestDTOinto anAdvertiserentity.toListResponseDTO(Collection<Advertiser> entities) Converts a collection ofAdvertiserentities into a list ofAdvertiserResponseDTO.toResponseDTO(Advertiser entity) Maps anAdvertiserentity to anAdvertiserResponseDTO.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
-
AdvertiserMapperImpl
public AdvertiserMapperImpl()
-
-
Method Details
-
toResponseDTO
Maps anAdvertiserentity to anAdvertiserResponseDTO.- Specified by:
toResponseDTOin interfaceGenericMapper<Advertiser,AdvertiserResponseDTO, AdvertiserRequestDTO> - Parameters:
entity- the Advertiser entity; may benull- Returns:
- the corresponding DTO, or
nullif the input entity isnull
-
toEntity
Converts anAdvertiserRequestDTOinto anAdvertiserentity. Defaults are applied for indexed, paid, and verified flags. The associated User is resolved viaIUserService.- Specified by:
toEntityin interfaceGenericMapper<Advertiser,AdvertiserResponseDTO, AdvertiserRequestDTO> - Parameters:
requestDTO- the request DTO; may benull- Returns:
- new Advertiser entity, or
nullif the input isnull
-
toListResponseDTO
Converts a collection ofAdvertiserentities into a list ofAdvertiserResponseDTO.- Specified by:
toListResponseDTOin interfaceGenericMapper<Advertiser,AdvertiserResponseDTO, AdvertiserRequestDTO> - Parameters:
entities- collection of Advertiser entities; may benullor empty- Returns:
- list of response DTOs; empty list if input is null or empty
-