Код: Выделить всё
Source{
String one;
String two;
}
Destination{
String one;
Child child;
}
Child{
String two;
}
main() {
ModelMapper modelMapper = new ModelMapper();
// what configurations to set here?
Source source = new Source("one=1", "two=2");
Destination desiredResult = new Destination();
desiredResult.setOne("one=1");
Destination mappedResult = modelmapper.map(source, Destination.class )
assertEquals(mappedResult, desiredResult );
}
Код: Выделить всё
1. modelMapper.getConfiguration().setPreferNestedProperties(false);
2. modelMapper.getConfiguration().setAmbiguityIgnored(true);
3. modelMapper.getConfiguration().setImplicitMappingEnabled(false);
4. modelMapper.addMappings(new PropertyMap() {
@Override
protected void configure() {
skip(destination.getChild());
skip(destination.getChild().getTwo());
}
});
Я надеюсь найти общее решение, которое сможет помешать сопоставителю модели сопоставлять свойства любого вложенного объекта в целевом объекте.>
Подробнее здесь: https://stackoverflow.com/questions/712 ... estination