0
すべての人(メンと女性)をオリカと同じPersonDtoにマップしたい。オリカのネストされた複数の出現要素
class Name {
private String first;
private String last;
private String fullName;
// getters/setters
}
class Womens{
private List<Name> names;
// getters/setters
}
class Mens{
private List<Name> names;
// getters/setters
}
class Person {
private Mens mens;
private Womens womens;
// getters/setters
}
class PersonDto {
private List<Info> info;
// getters/setters omitted
}
class Info {
private String notes;
// getters/setters omitted
}
私はメンズのみでテストしても問題ありません。
mapperFactory.classMap(Person.class, PersonDto.class)
.field("mens.names{first}", "info[0].notes")
.field("mens.names{last}", "info[1].notes")
.field("mens.names{fullName}", "info[2].notes")
.register();
私は唯一の女性でテストする場合、それは
mapperFactory.classMap(Person.class, PersonDto.class)
.field("womens.names{first}", "info[0].notes")
.field("womens.names{last}", "info[1].notes")
.field("womens.names{fullName}", "info[2].notes")
.register();
、OKですが、私はメンズとレディースでテストならば、それはKOです。インフォ配列は、良いサイズ、私は解決策を見つけるが、それは最善ではない
mapperFactory.classMap(Person.class, PersonDto.class)
.field("mens.names{first}", "info[0].notes")
.field("mens.names{last}", "info[1].notes")
.field("mens.names{fullName}", "info[2].notes")
.field("womens.names{first}", "info[3].notes")
.field("womens.names{last}", "info[4].notes")
.field("womens.names{fullName}", "info[5].notes")
.register();