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);
}
相关推荐
智码看视界20 分钟前
Day19 Spring Boot启动优化:启动时间从8秒降到2秒
java·spring boot·后端·启动优化
北京阿法龙科技有限公司39 分钟前
AR智能眼镜安防应用核心指标:识别距离筑牢防线
java·开发语言·ar
殘殤血1 小时前
Tomcat的事件监听机制:观察者模式 _
java·观察者模式·tomcat
汤姆yu1 小时前
面向具身智能的物理视频模拟器:蚂蚁灵波LingBot-Video开源模型全解析
java·大数据·人工智能·gpt·开源·大模型·音视频
SQL-First布道者1 小时前
Spring JDBC Ultra 十边型战士
java·spring boot·后端·mysql·spring·mybatis
殘殤血1 小时前
Tomcat的事件监听机制:观察者模式
java·观察者模式·tomcat
Java面试题总结1 小时前
GatewayWorker 从零到一完整指南
java
没钥匙的锁11 小时前
04-Java面向对象基础
java·开发语言·mongodb
脉动数据行情1 小时前
Java OkHttp 完整封装 GC COMEX 美黄金实时盘口定时拉取工具类
java·okhttp·comex 黄金·外盘贵金属
敖行客 Allthinker2 小时前
IM 融合专题:后端架构师的核心修炼
java·开发语言·数据库