java 两个list之间复制(beanUtils的copyproperties)

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