Class A {
private String a;
private String b;
private B innerObject;
}
Class B {
private String c;
}
In my case, String b might come in with a null value. My modelmapper configuration is like below:
ModelMapper mapper = new ModelMapper();
mapper.getConfiguration()
.setFieldMatchingEnabled(true)
.setMatchingStrategy(MatchingStrategies.LOOSE)
.setFieldAccessLevel(AccessLevel.PRIVATE)
.setSkipNullEnabled(true)
.setSourceNamingConvention(NamingConventions.JAVABEANS_MUTATOR);
when I map the object, I get the target object with b=null value.
Trying to stay away from a strategy shown here: SO- Question
What am I missing?
Have you tried this configuration:
modelMapper.getConfiguration().setPropertyCondition(Conditions.isNotNull());