package com.bonus.common.houqin.utils;

import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.util.ReflectUtil;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Objects;

public class CopyListUtil {
   private CopyListUtil() {
   }

   public static <T, M> List<T> copyListProperties(List<M> sources, Class<T> clazz) {
      if (!Objects.isNull(sources) && !Objects.isNull(clazz) && !sources.isEmpty()) {
         List<T> targets = new ArrayList(sources.size());
         Iterator var3 = sources.iterator();

         while(var3.hasNext()) {
            M source = (M) var3.next();
            T t = ReflectUtil.newInstance(clazz, new Object[0]);
            BeanUtil.copyProperties(source, t, new String[0]);
            targets.add(t);
         }

         return targets;
      } else {
         throw new IllegalArgumentException();
      }
   }
}
