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
相关推荐
Nelson_hehe2 小时前
Java基础第四章、面向对象Thomas_YXQ2 小时前
Unity3D Lua集成技术指南ShiinaMashirol3 小时前
代码随想录打卡|Day27(合并区间、单调递增的数字、监控二叉树)东阳马生架构5 小时前
Nacos简介—3.Nacos的配置简介北极的企鹅885 小时前
XML内容解析成实体类oioihoii5 小时前
C++23 中 static_assert 和 if constexpr 的窄化布尔转换聂 可 以5 小时前
调整IntelliJ IDEA当前文件所在目录(包路径)的显示位置东阳马生架构5 小时前
Sentinel源码—7.参数限流和注解的实现一李白的粉5 小时前
基于springboot的在线教育系统码农10087号5 小时前
Hot100方法及易错点总结2