package com.doumee.core.utils; import org.springframework.beans.BeanUtils; import java.util.List; import java.util.function.Supplier; import java.util.stream.Collectors; /** * Created by IntelliJ IDEA. * * @Author : Rk * @create 2025/12/12 9:31 */ public class ListUtil { public static List copyProperties(List sources, Supplier target) { return sources.stream().map(source -> { T t = target.get(); BeanUtils.copyProperties(source, t); return t; }).collect(Collectors.toList()); } public static List copyListProperties(List sources, Class target) { return sources.stream().map(source -> { T t; try { t = target.newInstance(); } catch (Exception e) { e.printStackTrace(); return null; } BeanUtils.copyProperties(source, t); return t; }).collect(Collectors.toList()); } }