Question

I need to map a property to several using Orika and am struggling to find a proper example.

Given the following classes:

public class A {
   String propertyA1
   String propertyB1
}

public class B {
   C cInstance;
   D dInstance;
   String propertyB2;
}

public class C {
   String propertyA2Part;
}

public class D {
   String propertyA3Part;
}

Basically I'm mapping class A to class B, but along the way I need to parse propertyA1 and send value to C.propertyA2Part and D.propertyA3Part. I'm trying to determine the best facility for this between a converter / mapper / filter.

Was it helpful?

Solution

I suppose that propertyA1 have to "splited" into two parts (C,D) In this case the more appropriate is to use .customize(CustomMapper).

Converter usually is used for simple mapping between some primitives, enum, immutable objects, copy by reference, and simple data type, it can be used for other thing but it is more appropriate for this kind of usage.

You can also look at tests of Orika, there is plenty of simple examples.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top