通用列表的 Dozer 映射
我有一个类似 ListWrapper
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;
}
和一个像 bean 的 bean
public class AccountBo {
private String accountName;
public String getAccountName() {
return accountName;
}
public void setAccountName(String accountName) {
this.accountName = accountName;
}
}
和另一个像 bean 的
public class AccountDto {
private String accountName;
public String getAccountName() {
return accountName;
}
public void setAccountName(String accountName) {
this.accountName = accountName;
}
}
想法,现在的想法是用 AccountBo 类型的 bean 填充列表,并使用 Dozer 映射列表,然后用 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();
但是 - 目标列表中的 Bean 类型为 AccountBo ....
我该怎么做才能获取 AccountDto 的列表?
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 String 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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论