Is it possible to map fields only if certain expression is met ? What are the approaches ?
For e.g
Let's say I have XYZ, XYZ and XYZMapper. Along side , there is a "SecurityUtils.isAdmin()"
method that provides boolean result to indicate whether it's admin or not. If its admin, i want Object b to be mapped else I want that value to be null.
@Getter
@Setter
public class XYZ{
private String a;
private Object b;
}
@Getter
@Setter
public class XYZDto{
private String a;
private Object b;
}
@Mapper(component="spring")
public interface XYZMapper{
XYZDto toXYZDto(XYZ xyz);
XYZ toXYZ(XYZDto xyzDto);
}
SecurityUtils.isAdmin() --> true of false