Reputation: 37
My TO structure is as follows
OneComplexCto
-List<ComplexEto>
--List<SimpleEto>
I want to get it mapped with itself (for firing ValueChangeListener)
So I want to map like,
OneComplexCto mapOneComplexCto(OneComplexCto source, @TargetMapping OneComplexCto target);
It's just mapping like,
oneComplexCto.setComplexEtos(target.getComplexEtos);
and I want it to map all the nasted ComplexEto's and all the SimpleEto's inside those ComplexEto's. (Aparently I want to call the setters for each individual fields).
Upvotes: 0
Views: 1960
Reputation: 21471
As you've noticed MapStruct will just invoke the setter in case the types are the same. In order to achieve a deep clone you would need to deifine mapping between all the types. In your case this would look like:
@Mapper
public interface ComplexMapper {
OneComplexCto mapOneComplexCto(OneComplexCto source, @MappingTarget OneComplexCto target);
List<ComplexEto> map(List<ComplexEto> complexEtos);
ComplexEto map(ComplexEto complexEto);
List<SimpleEto> map(List<SimpleEto> simpleEtos);
SimpleEto map(SimpleEto simpleEto);
}
You should follow and upvote mapstruct/mapstruct-695 which looking for something to allow MapStruct to disable the direct set of the same types and perform deep clone.
Upvotes: 1