修改获取类字段时,过滤重复字段(serialVersionUID)

pull/23/head
rays 2021-11-26 11:31:53 +08:00
parent a24c0b5b2f
commit 195fe94c7a
1 changed files with 5 additions and 2 deletions

View File

@ -36,6 +36,9 @@ import java.lang.annotation.Annotation;
import java.lang.reflect.*; import java.lang.reflect.*;
import java.util.*; import java.util.*;
import static java.util.Comparator.comparing;
import static java.util.stream.Collectors.toCollection;
/** /**
* *
* *
@ -81,10 +84,11 @@ public class ClassReflectUtil {
} }
runMap.remove(clazz.getName()); runMap.remove(clazz.getName());
// 获取本类的父类 // 获取本类的父类
clazz = clazz.getSuperclass(); clazz = clazz.getSuperclass();
} }
return fieldDescriptions; return fieldDescriptions.stream().collect(toCollection(() -> new TreeSet<>(comparing(FieldMetadata::getFieldName))));
} }
/** /**
@ -244,5 +248,4 @@ public class ClassReflectUtil {
return strings; return strings;
} }
} }