Reputation: 5857
Suppose I have a source object, containing two properties, a and b like this:
public class Source {
String a, b;
}
and a target object with one property c:
public class Target {
String c;
}
I'd like to define a mapping that will:
I thought it would be possible with a mapper with mapNulls set to false:
factory.registerClassMap(factory.classMap(Source.class, Target.class).field("a", "c").field("b", "c").mapNulls(false));
However, when I set property a to a non-null value and leave property b to null, the mapping results in a target object with c set to null.
Have I misunderstood the purpose of mapNulls?
Upvotes: 1
Views: 1602
Reputation: 2204
It's because mapNulls
set the property at the last field.
Try setting at both fields.
You can implement a ConfigurableMapper
too.
Upvotes: 1