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);
}
相关推荐
camellias_1 小时前
【无标题】
java·tomcat
咸鱼2.01 小时前
【java入门到放弃】需要背诵
java·开发语言
椰猫子1 小时前
Java:异常(exception)
java·开发语言
win x2 小时前
Redis 使用~如何在Java中连接使用redis
java·数据库·redis
星晨雪海3 小时前
基于 @Resource 的支付 Service 多实现类完整示例
java·开发语言
阿维的博客日记3 小时前
什么是逃逸分析
java·juc
Ricky_Theseus3 小时前
C++右值引用
java·开发语言·c++
Rick19933 小时前
Java内存参数解析
java·开发语言·jvm
我是大猴子4 小时前
Spring代理类为何依赖注入失效?
java·后端·spring
勿忘,瞬间4 小时前
多线程之进阶修炼
java·开发语言