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
Advertiser
entity into anAdvertiserResponseDTO
. - Construct an
Advertiser
entity 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 anAdvertiserRequestDTO
into anAdvertiser
entity.toListResponseDTO
(Collection<Advertiser> entities) Converts a collection ofAdvertiser
entities into a list ofAdvertiserResponseDTO
.toResponseDTO
(Advertiser entity) Maps anAdvertiser
entity to anAdvertiserResponseDTO
.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
-
AdvertiserMapperImpl
public AdvertiserMapperImpl()
-
-
Method Details
-
toResponseDTO
Maps anAdvertiser
entity to anAdvertiserResponseDTO
.- Specified by:
toResponseDTO
in interfaceGenericMapper<Advertiser,
AdvertiserResponseDTO, AdvertiserRequestDTO> - Parameters:
entity
- the Advertiser entity; may benull
- Returns:
- the corresponding DTO, or
null
if the input entity isnull
-
toEntity
Converts anAdvertiserRequestDTO
into anAdvertiser
entity. Defaults are applied for indexed, paid, and verified flags. The associated User is resolved viaIUserService
.- Specified by:
toEntity
in interfaceGenericMapper<Advertiser,
AdvertiserResponseDTO, AdvertiserRequestDTO> - Parameters:
requestDTO
- the request DTO; may benull
- Returns:
- new Advertiser entity, or
null
if the input isnull
-
toListResponseDTO
Converts a collection ofAdvertiser
entities into a list ofAdvertiserResponseDTO
.- Specified by:
toListResponseDTO
in interfaceGenericMapper<Advertiser,
AdvertiserResponseDTO, AdvertiserRequestDTO> - Parameters:
entities
- collection of Advertiser entities; may benull
or empty- Returns:
- list of response DTOs; empty list if input is null or empty
-