java 泛型拷貝 List指定Class

private List parse(List list,Class toClazz){
List resp=Lists.newArrayListWithCapacity(list.size());
resp=(List )list.stream().map(ff->{
Object obj= toClazz.newInstance();
BeanUtils.copyProperties(ff,obj);
return obj;
}).collect(Collectors.toList());
return resp;
}

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章