/** 获取接口的泛型类型 */
public static Class<?> getParameterizedType(Class<?> clazz) {
try {
Type[] a = clazz.getGenericInterfaces();
if (a != null && a.length > 0) {
for (Type type : a) {
if (type instanceof ParameterizedType) {
ParameterizedType type1 = (ParameterizedType) type;
Class<?> cal = (Class<?>) type1
.getActualTypeArguments()[0];
if (BaseRespEntity.class.isAssignableFrom(cal)) {
return cal;
}
}
}
}
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
获取接口的泛型类型
最新推荐文章于 2023-12-24 10:36:38 发布