The parent class declares generics

example:
    class A extends B <C> {}
    class B<T> {
        List<T> lists;
    }
    class C {
        String name;
    }
This commit is contained in:
yao.hq 2021-09-01 13:42:47 +08:00 committed by GitHub
parent ea3d13a9b5
commit fe3765f1cb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 1 deletions

View File

@ -82,6 +82,13 @@ public class ParamsBuildHelper {
String simpleName = DocClassUtil.getSimpleName(className);
String[] globGicName = DocClassUtil.getSimpleGicName(className);
JavaClass cls = projectBuilder.getClassByName(simpleName);
if (globGicName == null || globGicName.length <= 0) {
//获取父类的泛型
JavaClass superJavaClass = cls != null ? cls.getSuperJavaClass() : null;
if (superJavaClass != null && !"Object".equals(superJavaClass.getSimpleName())) {
globGicName = DocClassUtil.getSimpleGicName(superJavaClass.getGenericFullyQualifiedName());
}
}
JavaClassUtil.genericParamMap(genericMap, cls, globGicName);
List<DocJavaField> fields = JavaClassUtil.getFields(cls, 0, new LinkedHashMap<>());