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);
}
相关推荐
努力学编程呀(๑•ี_เ•ี๑)5 分钟前
【在 IntelliJ IDEA 中切换项目 JDK 版本】
java·开发语言·intellij-idea
码农小卡拉15 分钟前
深入解析Spring Boot文件加载顺序与加载方式
java·数据库·spring boot
向上的车轮22 分钟前
为什么.NET(C#)转 Java 开发时常常在“吐槽”Java:checked exception
java·c#·.net
Dragon Wu24 分钟前
Spring Security Oauth2.1 授权码模式实现前后端分离的方案
java·spring boot·后端·spring cloud·springboot·springcloud
跳动的梦想家h30 分钟前
环境配置 + AI 提效双管齐下
java·vue.js·spring
坚持就完事了31 分钟前
Java中的集合
java·开发语言
wjhx40 分钟前
QT中对蓝牙权限的申请,整理一下
java·数据库·qt
YCY^v^44 分钟前
JeecgBoot 项目运行指南
java·学习
人间打气筒(Ada)1 小时前
jenkins基于Pipeline发布项目
java·pipeline·jenkins·流水线·ci·cd·cicd
爬山算法1 小时前
Hibernate(88)如何在负载测试中使用Hibernate?
java·后端·hibernate