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
相关推荐
金銀銅鐵24 分钟前
[Java] 展示增删元素时 LinkedList 的内部变化布吉岛的石头1 小时前
Java 程序员第 50 阶段3:数据工程:预训练语料清洗与去重大文说跨境1 小时前
防关联浏览器的指纹覆盖到什么程度:六类参数的实测与自检方法Carol06302 小时前
上肢及肩肘关节yliucherish2 小时前
Log4Shell 复现实录:我读 OpenJDK 源码,发现两道防线的默认值竟然相反维拉德2 小时前
Java新人第一次接打标需求:从抓包找接口到客户端展示luobobo8962 小时前
支付回调验签连续失败三天,最后发现是网关的时间戳单位问题BBmmo2 小时前
Java InputStream.read() 为什么返回 int?Nuanyt2 小时前
LeetCode Hot100 刷题笔记 · 普通数组专题cfm_29144 小时前
Leaf-segment号段模式