I have the following mapper:
@Mapper(
collectionMappingStrategy = CollectionMappingStrategy.ADDER_PREFERRED,
unmappedTargetPolicy = ReportingPolicy.IGNORE,
componentModel= "spring",
uses = {
KeyMapper.class,
SubscriptionMapper.class
}
)
public interface ConfigurationMapper {
ConfigurationDto toDto(Configuration configuration);
ConfigurationApiDto toApiDto(Configuration configuration);
@BeforeMapping
default void filterSubscriptionsAndKeys(
Configuration configuration,
@MappingTarget ConfigurationApiDto configurationApiDto
) {
configuration.getSubscriptions().removeIf(subscription -> subscription.getUnsubscribedAt() != null);
configuration.geKeys().removeIf(key -> key.getRevokedAt() != null);
}
}```
But when MapStruct generates the implication and I use the toApiDto function in another mapper, I get the following error:
NullPointerException -> KeyMapper and SubscriptionMapper is null.
While when I use the toDto function everything works fine. (FYI the toDto as the toApiDto use the same Mappers)