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
相关推荐
8***f3956 分钟前
Spring容器初始化扩展点:ApplicationContextInitializerr_oo_ki_e_12 分钟前
java22--常用类linweidong23 分钟前
C++ 中避免悬挂引用的企业策略有哪些?用户937611475816125 分钟前
并发编程三大特性阿在在26 分钟前
Spring 系列(二):加载 BeanDefinition 的几种方式小当家.10534 分钟前
Maven与Gradle完整对比指南:构建工具深度解析neoooo41 分钟前
🍃Spring Boot 多模块项目中 Parent / BOM / Starter 的正确分工黄金贼贼42 分钟前
2026最新java单元测试json校验器菜鸟的迷茫42 分钟前
为了防雪崩加了限流,结果入口先挂了荒诞硬汉44 分钟前
数组常见算法