I would like to use mapstruct to map between these objects:
MyObj1
-List<MyObj2> myObj2List
--List<MyObj3> myObj3List
---string field1
MyObj4
-List<MyObj5> myObj5List
--List<MyObj6> myObj6List
---int field1
Question: can i somehow tell mapstruct to map the field1 from string to int OTHERWISE than the default Integer.parseInt(...)
?
Changing the types of the inner objects is not an option. I know there is an annotaion
@Mapping(source = "myObj2List.myObj3List.field1", target = "myObj5List.myObj6List.field1", qualifiedByName = "methodToMapWith")
public MyObj4 field1Mapper(MyObj1input);
@Named("methodToMapWith")
public static int methodToMapWith(string input) {
return ...[custom logic]...;
}
but since these are nested objects, this way i get an error saying No property named "myObj2List.myObj3List.field1" exists in source parameter(s).
I must be formulating the source wrong. Any help please?