TypeToken.getGenericType加强

This commit is contained in:
Redkale
2020-02-09 12:37:00 +08:00
parent 7340caa4a9
commit 29148c4b42

View File

@@ -159,6 +159,20 @@ public abstract class TypeToken<T> {
return atas[i];
}
}
ParameterizedType cycType = superPT;
if (cycType.getRawType() instanceof Class) {
TypeVariable[] argTypes = ((Class) cycType.getRawType()).getTypeParameters();
if (argTypes.length == asts.length) {
for (int i = 0; i < argTypes.length; i++) {
if (argTypes[i] == type) {
if (atas[i] instanceof TypeVariable
&& ((TypeVariable) atas[i]).getBounds().length == 1
&& ((TypeVariable) atas[i]).getBounds()[0] instanceof Class)
return ((Class) ((TypeVariable) atas[i]).getBounds()[0]);
}
}
}
}
}
Type moreType = ((ParameterizedType) superType).getRawType();
if (moreType != Object.class) return getGenericType(type, moreType);