public class UTypeUtil extends Object
| Constructor and Description |
|---|
UTypeUtil() |
| Modifier and Type | Method and Description |
|---|---|
static Class<?> |
getClass(Field field)
获得Field对应的原始类
|
static Class<?> |
getClass(Type type)
获得Type对应的原始类
|
static Class<?> |
getFirstParamClass(Method method)
获取方法的第一个参数类
|
static Type |
getFirstParamType(Method method)
获取方法的第一个参数类型
优先获取方法的GenericParameterTypes,如果获取不到,则获取ParameterTypes |
static Class<?> |
getParamClass(Method method,
int index)
获取方法的参数类
|
static Class<?>[] |
getParamClasses(Method method)
解析方法的参数类型列表
依赖jre\lib\rt.jar |
static Type |
getParamType(Method method,
int index)
获取方法的参数类型
优先获取方法的GenericParameterTypes,如果获取不到,则获取ParameterTypes |
static Type[] |
getParamTypes(Method method)
获取方法的参数类型列表
优先获取方法的GenericParameterTypes,如果获取不到,则获取ParameterTypes |
static Class<?> |
getReturnClass(Method method)
解析方法的返回类型类列表
|
static Type |
getReturnType(Method method)
获取方法的返回值类型
获取方法的GenericReturnType |
static Type |
getType(Field field)
获取字段对应的Type类型
方法优先获取GenericType,获取不到则获取Type |
static Type |
getTypeArgument(Class<?> clazz,
int index)
获得给定类的泛型参数
|
static Type |
getTypeArgument(Type type)
获得给定类的第一个泛型参数
|
static Type |
getTypeArgument(Type type,
int index)
获得给定类的泛型参数
|
static Type[] |
getTypeArguments(Type type)
获得指定类型中所有泛型参数类型
|
public static Class<?> getClass(Type type)
type - Typenullpublic static Type getType(Field field)
field - 字段Type,可能为nullpublic static Class<?> getClass(Field field)
field - Fieldnullpublic static Type getTypeArgument(Class<?> clazz, int index)
clazz - 被检查的类,必须是已经确定泛型类型的类index - 泛型类型的索引号,既第几个泛型类型Typepublic static Type getTypeArgument(Type type, int index)
type - 被检查的类型,必须是已经确定泛型类型的类index - 泛型类型的索引号,既第几个泛型类型Typepublic static Type[] getTypeArguments(Type type)
type - 指定类型public static Type[] getParamTypes(Method method)
method - 方法Type列表,可能为nullMethod.getGenericParameterTypes(),
Method.getParameterTypes()public static Type getParamType(Method method, int index)
method - 方法index - 第几个参数的索引,从0开始计数Type,可能为nullpublic static Class<?> getReturnClass(Method method)
method - 方法Method.getGenericReturnType(),
Method.getReturnType()public static Class<?> getFirstParamClass(Method method)
method - 方法nullpublic static Class<?> getParamClass(Method method, int index)
method - 方法index - 第几个参数的索引,从0开始计数nullpublic static Class<?>[] getParamClasses(Method method)
method - t方法Method.getGenericParameterTypes(),
Method.getParameterTypes()public static Type getReturnType(Method method)
method - 方法Type,可能为nullMethod.getGenericReturnType(),
Method.getReturnType()public static Type getFirstParamType(Method method)
method - 方法Type,可能为nullCopyright © 2020. All rights reserved.