class Foo {
String name = "foo";
Bar bar;
}
class Bar {
String name = "bar";
}
class FooDto {
@Mapping(field="name")
String fooName;
@Mapping(field="bar.name")
String barName;
@Mapping(field="this")
String bar;
}
FooDto fooDto = BeanUtils.copyProperties(foo, FooDto.class);
System.out.println(fooDto.getFooName()); // "foo"
System.out.println(fooDto.getBarName()); // "bar"
System.out.println(fooDto.getBar()); // "Foo{name='foo', bar=Bar{name='bar'}}"