-
-
Notifications
You must be signed in to change notification settings - Fork 1k
Closed
Labels
Milestone
Description
Hi,
We want to apply source presence tracking recursively. For example:
//source object
public class SourceA {
private String fieldA;
private SourceB fieldB;
//getters & setters & hasXXX methods
...
}
public class SourceB {
private String fieldC;
//getters & setters & hasXXX methods
...
}
//target
public class TargetObj {
private String fieldA;
private String fieldC;
//getters & setters
...
}
//mapper
@Mapper(nullValueCheckStrategy = NullValueCheckStrategy.ALWAYS)
public interface TestMapper {
@Mapping(source = "fieldB.fieldC", target = "fieldC")
TargetObj testMap(SourceA source);
}
//The auto generated code:
public TargetObj testMap(SourceA source) {
if(source == null) {
return null;
} else {
TargetObj targetObj = new TargetObj();
String fieldC = this.sourceFieldBFieldC(source);
if(source.hasFieldB()) {
targetObj.setFieldC(fieldC);
}
if(source.hasFieldA()) {
targetObj.setFieldA(source.getFieldA());
}
return targetObj;
}
}
...
When mapping fieldC, source presence tracking has only applied to it's parent object,
if(source.hasFieldB()) {
targetObj.setFieldC(fieldC);
}
However we want to apply source presence tracking recursively:
if(source.hasFieldB() && source.getFieldB().hasFieldC()) {
targetObj.setFieldC(fieldC);
}
Is this some feature you can support? Thanks!