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);
}
相关推荐
程序猿零零漆3 分钟前
SpringCloud系列教程:微服务的未来(二十)Seata快速入门、部署TC服务、微服务集成Seata
java·spring·spring cloud·微服务
我的K84091 小时前
Spring Boot基本项目结构
java·spring boot·后端
码农小苏242 小时前
K个不同子数组的数目--滑动窗口--字节--亚马逊
java·数据结构·算法
CodeClimb2 小时前
【华为OD-E卷 - 最大矩阵和 100分(python、java、c++、js、c)】
java·c++·python·华为od·矩阵
独自破碎E2 小时前
【4】阿里面试题整理
java·开发语言·算法·排序算法·动态规划
customer089 小时前
【开源免费】基于SpringBoot+Vue.JS体育馆管理系统(JAVA毕业设计)
java·vue.js·spring boot·后端·开源
Miketutu10 小时前
Spring MVC消息转换器
java·spring
乔冠宇10 小时前
Java手写简单Merkle树
java·区块链·merkle树
LUCIAZZZ11 小时前
简单的SQL语句的快速复习
java·数据库·sql
komo莫莫da11 小时前
寒假刷题Day19
java·开发语言