How can I map the following:
class Source {
String name;
List<Other> others;
}
class Other {
String otherName;
List<More> mores;
}
class More {
String moreName;
}
class Target {
String name;
String otherName;
String moreName;
}
Hoping it could be something like:
@Mapper
public interface MyMapper {
@Mapping(target = "name", source = "name")
@Mapping(target = "otherName", source = "others[0].otherName")
@Mapping(target = "morename", source = "others[0].mores[0].moreName")
Target map(Source source);
I see that 'expression = "java(others.get(0).otherName)"' can be used but there are no null checks when using expression, which could result in NullPointeException. Any suggestions with null checks and default can be applied?