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);
}
相关推荐
郑州光合科技余经理8 分钟前
实战:攻克海外版同城生活服务平台开发五大挑战
java·开发语言·javascript·数据库·git·php·生活
蟹至之9 分钟前
【MySQL】JDBC的使用(万字解析)
java·数据库·mysql·jdbc
爱笑的眼睛1110 分钟前
超越翻转与裁剪:面向生产级AI的数据增强深度实践与多模态演进
java·人工智能·python·ai
长孙阮柯11 分钟前
Java进阶篇(五)
java·开发语言
小张快跑。25 分钟前
Maven指定版本下载以及相关配置
java·maven
zhishidi27 分钟前
Spring @Scheduled注解调度机制详解
java·python·spring
⑩-27 分钟前
Blocked与Wati的区别
java·开发语言
AAA简单玩转程序设计29 分钟前
救命!Java这3个小技巧,写起来爽到飞起✨
java
IManiy36 分钟前
Java表达式引擎技术选型分析(SpEL、QLExpress)
java·开发语言
历程里程碑44 分钟前
C++ 17异常处理:高效捕获与精准修复
java·c语言·开发语言·jvm·c++