import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
+import java.util.ArrayList;
+import java.util.Comparator;
import java.util.Date;
+import java.util.List;
+import java.util.TreeSet;
+import java.util.stream.Collectors;
import javax.persistence.Column;
import javax.persistence.Id;
*
*/
public class EntityUtils {
+
+
+ public static <T extends ABaseEntity> List<T> distinctList(List<T> list) {
+ return list.stream()
+ .collect(
+ Collectors.collectingAndThen(
+ Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(T::getId))), ArrayList<T>::new
+ )
+ );
+ }
/**
* 合并 domain 中带有{@link Column}注解的字段值, 将 newEntity 中值为null的字段,使用 oldEntity 中的值