I am using mapstruct and trying to map 2 different types of objects. That is the requirement.
Target Object structure is as below(Hierarchial)
List<Object1>
Object1 have List<Object2>
Object 2 have List<Object3>
Object 3 have List<Object4>
And each one have String Objects to map from source respective ListObject and StringObject
SourceObject have in same class:
List<SourceObject1>
List<SourceObject2>
List<SourceOject3>
Mapping requirement is:
Object1 have to map with SourceObject1
Object2 have to map with SourceObject2
Object3 have to map with SourceObject3
I am using 1.2.0.Final version and able to map Object1 have to map with SourceObject1
//List to List mapping
@Mapping(target = "Object1", source = "SourceObject1")
Target from(Source);
@Mapping(target = "Object1[0].Object2", source = "SourceObject2")
Mapping(target = "Object1[0].Object3", source = "SourceObject3")
//not casting and not mapping working.Also Need to map String fields under
list Object.