I'm trying to map a model of a webservice where every List is inside nested object to something more simple.
- Model 1
public class Parent { private Children children; } public class Children { private List<Child> children; } public class Child { }
- Model 2(simplified)
public class Parent2 { private List<Child2> children; } public class Child { }
The mapping is pretty straightforward:
@Mappings({@Mapping(source = "entity.children.children", target = "children")}) Parent2 parentToParent2(Parent entity); @InheritInverseConfiguration Parent parent2ToParent(Parent2 entity);
Mapping works fine except for one problem. When I map Parent with null children to Parent2 and back to Parent, the Children object is created with empty list. Is there some way to prevent that?
Parenthaving non nullChildrenobject with a nullchildrenfield (Parent.childrenis non-null,Parent.children.childrenis null). What would you expect?Parent.childrento be null? - jannis