I have the following class:
public class A{
List<AA> aaList;
public A(List<AA> aaList){
this.aaList = aaList;
}
//getters and setters + default constructor
public class AA {
String aaString;
public AA(String aaString){
this.aaString = aaString;
}
//getters and setters + default constructor
}
}
And I want to have two objects of the same class, let's say:
A a = new A(Arrays.asList(new A.AA(null)));
A a2 = new A(Arrays.asList(new A.AA("test")));
and when I map a
to a2
, a2
should remain test
because a
has a null
.
How can I configure this with Orika
?
I tried something like:
mapperFactory.classMap(A.AA.class, A.AA.class)
.mapNulls(false)
.byDefault()
.register();
mapperFactory.classMap(A.class, A.class)
.mapNulls(false)
.customize(new CustomMapper<A, A>() {
@Override public void mapAtoB(A a, A a2,
MappingContext context) {
map(a.getAAList(), a2.getAAList());
}
})
.byDefault()
.register();
Thanks in advance
a
toa2
? I mean did you try? I am confused about it. – Malonylurea