Reputation: 11
Using Orika how do I map multiple single Strings into a List of Strings?
Given:
Class A
String field1
String field2
String field3
Class B
List fields
So field1, field2 and field 3 will all be elements in fields. How do I code Orika to handle this?
Upvotes: 1
Views: 633
Reputation: 1739
You can do it using
factory.classMap(ClassA.class, ClassB.class)
.byDefault()
.customize(new CustomMapper<ClassA, ClassB>() {
public void mapAToB(ClassA source, ClassB dest) {/*custom logic*/}
public void mapBToA(ClassB source, ClassA dest) {/*custom logic*/}
})
.register();
In CustomMapper you can to override only the desired direction of mapping or both if needed. This way Orika will handle all automatic mapping and you can still use java code to customize the process.
Upvotes: 2