package com.crm.rely.backend.util;

import org.springframework.beans.BeanUtils;

import java.util.List;
import java.util.function.Supplier;
import java.util.stream.Collectors;

public class SearchServiceUtil {

    public static <S, T> List<T> copyList(List<S> source, Supplier<T> targetSupplier) {
        return source.stream().map(s -> {
            T t = targetSupplier.get();
            BeanUtils.copyProperties(s, t);
            return t;
        }).collect(Collectors.toList());
    }

}
