BeanCopy 复制

集合 复制到 集合

public static <T> List copyBeanList(List resourceList, Class<T> target) {
    List targetList = new LinkedList<>();
    if (null == resourceList || resourceList.isEmpty()) {
        return targetList;
    }
    resourceList.forEach(e -> {
        T o = null;
        try {
            o =  target.newInstance();
        } catch (Exception ex) {
            ex.printStackTrace();
        }
        BeanUtils.copyProperties(e, o);
        targetList.add(o);
    });
    return targetList;
}

 

posted @ 2022-06-28 13:34  yifanSJ  阅读(306)  评论(0编辑  收藏  举报