作者:Lanboream | 来源:互联网 | 2024-11-15 09:33
packagecom.panchan.tsmese.utils;importjava.lang.reflect.ParameterizedType;importjava.lang.
package com.panchan.tsmese.utils;
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
/**
* @Description:TODO
* @version 1.0
* @since JDK1.8
* @author
* @Created on 2018年9月19日
*/
public class FatherReflectUtils {
/**
* 获取父类的参数类型方法
* @param clazz
* @param index
* @return
* @throws InstantiationException
* @throws IllegalAccessException
*/
@SuppressWarnings("rawtypes")
public static Class getSuperClassParamType(Class> clazz, int index) throws InstantiationException, IllegalAccessException {
Type sType = clazz.getGenericSuperclass();
Type[] generics = ((ParameterizedType) sType).getActualTypeArguments();
Class> mClass = (Class>) (generics[index]);
return mClass;
}
}