public static <T> List<T> copyPropertiesOfList(List<?> sourceList, Class<T> targetClass, boolean useConverter) { if (CollectionUtils.isEmpty(sourceList)) { return Collections.emptyList(); } List<T> resultList = new ArrayList<>(sourceList.size()); for (Object o : sourceList) { T t = null; try { t = targetClass.newInstance(); copyPropertiesOfList(o, t, useConverter); resultList.add(t); } catch (Exception e) { throw new RuntimeException(e); } } return resultList; } private static <T>void copyPropertiesOfList(Object soruces, T target, boolean useConverter){ if (useConverter) copyProperties(soruces, target, useConverter); else copyProperties(soruces, target); }
java 两个list之间复制(beanUtils的copyproperties)
林鸟鸟2023-08-23 8:43
相关推荐
无声旅者5 分钟前
深度解析 IDEA 集成 Continue 插件:提升开发效率的全流程指南Ryan-Joee28 分钟前
Spring Boot三层架构设计模式Hygge-star33 分钟前
【数据结构】二分查找5.12dkmilk1 小时前
Tomcat发布websocket工一木子1 小时前
【Java项目脚手架系列】第七篇:Spring Boot + Redis项目脚手架哞哞不熬夜1 小时前
JavaEE--初识网络等等5432 小时前
Java EE初阶——wait 和 notifyAPI小爬虫2 小时前
淘宝按图搜索商品(拍立淘)Java 爬虫实战指南lyrhhhhhhhh2 小时前
Spring 框架 JDBC 模板技术详解亚林瓜子3 小时前
AWS Elastic Beanstalk控制台部署Spring极简工程