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);
}
相关推荐
caishenzhibiao几秒前
顺势捕猎者副图 同花顺期货通指标
java·c语言·c#
笨蛋不要掉眼泪31 分钟前
RabbitMQ消息队列:SpringAMQP
java·分布式·rabbitmq
Mark_ZP1 小时前
【锁6】AQS (AbstractQueuedSynchronizer) 核心原理详解
java
AI砖家1 小时前
多商户多租户系统架构设计文档(Java版)
java·开发语言·系统架构·多租户·多商户
落苜蓿蓝1 小时前
Java 循环中对象复用导致属性覆盖?从 JVM 内存模型讲解原因
java·jvm·python
weixin_440784111 小时前
Android基础知识汇总
android·java·android studio
布鲁飞丝1 小时前
从零实现富文本编辑器#-浏览器选区与编辑器选区模型同步
java·前端·编辑器
jun_bai2 小时前
使用java安全的移动文件
java
caishenzhibiao2 小时前
市场同步系统 同花顺期货通指标
java·c语言·c#
Devin~Y2 小时前
从本地生活电商到 AI RAG:互联网大厂 Java 面试场景完整实战
java·spring boot·redis·elasticsearch·spring cloud·kafka·rag