public class GenericsUtils extends Object
Constructor and Description |
---|
GenericsUtils() |
Modifier and Type | Method and Description |
---|---|
static Class |
getFieldGenericType(Field field)
通过反射,获得Field泛型参数的实际类型.
|
static Class |
getFieldGenericType(Field field,
int index)
通过反射,获得Field泛型参数的实际类型.
|
static List<Class> |
getMethodGenericParameterTypes(Method method)
通过反射,获得方法输入参数第一个输入参数的所有泛型参数的实际类型.
|
static List<Class> |
getMethodGenericParameterTypes(Method method,
int index)
通过反射,获得方法输入参数第index个输入参数的所有泛型参数的实际类型.
|
static Class |
getMethodGenericReturnType(Method method)
通过反射,获得方法返回值第一个泛型参数的实际类型.
|
static Class |
getMethodGenericReturnType(Method method,
int index)
通过反射,获得方法返回值泛型参数的实际类型.
|
static Class |
getSuperClassGenericType(Class clazz)
通过反射,获得指定类的父类的第一个泛型参数的实际类型.
|
static Class |
getSuperClassGenericType(Class clazz,
int index)
通过反射,获得指定类的父类的泛型参数的实际类型.
|
public static Class getSuperClassGenericType(Class clazz, int index)
clazz
- clazz 需要反射的类,该类必须继承范型父类index
- 泛型参数所在索引,从0开始.Object.class
public static Class getSuperClassGenericType(Class clazz)
clazz
- clazz 需要反射的类,该类必须继承泛型父类Object.class
public static Class getMethodGenericReturnType(Method method, int index)
method
- 方法index
- 泛型参数所在索引,从0开始.Object.class
public static Class getMethodGenericReturnType(Method method)
method
- 方法Object.class
public static List<Class> getMethodGenericParameterTypes(Method method, int index)
method
- 方法index
- 第几个输入参数public static List<Class> getMethodGenericParameterTypes(Method method)
method
- 方法public static Class getFieldGenericType(Field field, int index)
field
- 字段index
- 泛型参数所在索引,从0开始.Object.class
Copyright © 2014. All Rights Reserved.