Dozer mapping of generic lists
I have a ListWrapper like
public class ListWrapper<T> {
private List<T> entries = new ArrayList<T>();
public List<T> getEntries() {
return entries;
}
public void setEntries(List<T> entries) {
this.entries = entries;
}
and a bean like
public class AccountBo {
private Stri开发者_Python百科ng accountName;
public String getAccountName() {
return accountName;
}
public void setAccountName(String accountName) {
this.accountName = accountName;
}
}
and another bean like
public class AccountDto {
private String accountName;
public String getAccountName() {
return accountName;
}
public void setAccountName(String accountName) {
this.accountName = accountName;
}
}
the idea now is to fill the list with beans of type AccountBo and use Dozer to map the list, then filled with AccountDto Beans.
AccountBo accountA = new AccountBo();
accountA.setAccountName("Person A");
AccountBo accountB = new AccountBo();
accountB.setAccountName("Person B");
ListWrapper<AccountBo> listWrapperBo = new ListWrapper();
listWrapperBo.getEntries().add(accountA);
listWrapperBo.getEntries().add(accountB);
ListWrapper<AccountDto> dtoList = EntityMapper.getInstance().map(listWrapperBo, ListWrapper.class);
List<AccountDto> listDto = dtoList.getEntries();
But - the Beans in the target list are of type AccountBo ....
What can I do to get a list of AccountDto's?
精彩评论