-
-
Notifications
You must be signed in to change notification settings - Fork 1k
Closed
Labels
Milestone
Description
With #2051 we added support for conditional mappings. Currently this only works for properties. However, it would be good to be able to apply the same logic for the source parameters.
e.g. If we have the following mapper
@Mapper
public interface CarMapper {
CarDto map(Car car);
}We currently generated something like:
public class CarMapperImpl implements CarMapper {
public CarDto map(Car car) {
if ( car == null ) {
return null;
}
// perform mapping
}
}It would be good to be able to define a custom method that would tell is if the car should be mapped or not:
e.g. we could generate something like
public class CarMapperImpl implements CarMapper {
public CarDto map(Car car) {
if ( isCarPresent(car) ) {
return null;
}
// perform mapping
}
}where isCarPresent is a method on the CarMapper. It can be a method that is available anywhere in the same discovery mechanism we have for the property conditional methods.
I believe that this issue is not super difficult to implement and would appreciate if someone from the community is interested in stepping up.