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
相关推荐
Pniubi11 分钟前
怎么排查慢SQL,怎么解决?薛之谦_1 小时前
Java 全栈知识体系:从 IDEA 高效开发到 JVM、并发与 Stream 实战文丑颜不良啊5 小时前
LeetCode2761~2780题目解析IT枫斗者枫哥6 小时前
子线程断言失败,JUnit 为什么还显示通过?考虑考虑8 小时前
JDK27中的Set.ofLazy文丑颜不良啊8 小时前
LeetCode2841~2860题目解析小南家的青蛙8 小时前
Tomcat与Jetty深度对比乌暮10 小时前
Spring AOP 与 Spring 事务:用大白话彻底理解原理与实践YDS82910 小时前
Small Spring IOC篇:容器事件及其监听器金銀銅鐵10 小时前
带您看懂字节码指令(三):一行加法里有什么