1

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.

4

1 回答 1

1

我想propertyA1必须“拆分”成两部分(C,D)在这种情况下,更合适的是使用.customize(CustomMapper)。

转换器通常用于一些原语、枚举、不可变对象、引用复制和简单数据类型之间的简单映射,它可以用于其他事物,但更适合这种用法。

你也可以看看 Orika 的测试,有很多简单的例子。

于 2014-02-28T09:36:18.050 回答