Listlist2= list1.stream() .map(e -> { PoolCodeDto codeDto = new PoolCodeDto(); BeanUtils.copyProperties(e, codeDto); codeDto.setPoolCode(e.getDictCode()); codeDto.setH5Url(e.getDictValue()); codeDto.setWechatUrl(e.getDescription()); return codeDto; }).collect(Collectors.toList());
2.Java中对象拷贝
public static V copyBean(Object source, Class clazz) {
V result = null;
try {
result = clazz.newInstance();
Assert.notNull(source, "Source must not be null");
BeanUtils.copyProperties(source, result);
} catch (Exception e) {
e.printStackTrace();
}
return result;
}
3.java中集合对象拷贝
public static List copyBeanList(List list, Class clazz) {
return list.stream()
.map(o -> copyBean(o, clazz))
.collect(Collectors.toList());
}



