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); }
java 两个list之间复制(beanUtils的copyproperties)
林鸟鸟2023-08-23 8:43
相关推荐
碳水加碳水3 分钟前
Java代码审计实战:XML外部实体注入(XXE)深度解析努力也学不会java1 小时前
【设计模式】 原型模式方渐鸿1 小时前
【2024】k8s集群 图文详细 部署安装使用(两万字)学亮编程手记2 小时前
K8S v1.33 版本主要新特性介绍Haven-3 小时前
Java-面试八股文-JVM篇我真的是大笨蛋3 小时前
JVM调优总结wjs0403 小时前
Git常用的命令superlls3 小时前
(算法 哈希表)【LeetCode 349】两个数组的交集 思路笔记自留田里的水稻4 小时前
C++_队列编码实例,从末端添加对象,同时把头部的对象剔除掉,中的队列长度为设置长度NUM_OBJponnylv4 小时前
深入剖析Spring Boot启动流程