ublic 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(T soruces, T target, boolean useConverter){ if (useConverter) cn.hutool.core.bean.BeanUtil.copyProperties(soruces, target, useConverter); else copyProperties(soruces, target); }
文章来源地址https://www.toymoban.com/news/detail-666049.html
文章来源:https://www.toymoban.com/news/detail-666049.html
到了这里,关于java 两个list之间复制(beanUtils的copyproperties)的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!