public class MethodReflectUtil extends Object
| 构造器和说明 |
|---|
MethodReflectUtil() |
| 限定符和类型 | 方法和说明 |
|---|---|
static List<Annotation> |
getMethodFirstParamAnnotations(Method method)
获取方法上的注解
注意,此方法只获取方法第一个参数的所有注解
|
static Type[] |
getMethodGenericTypes(Method method)
返回方法的所有类型参数信息
|
static List<ParameterMetadata> |
getMethodParameterInfos(Method method)
获取方法的所有参数元数据信息
|
static Type |
getMethodReturnType(Method method)
获取方法的返回值type类型,type可能是class也可能是带泛型的类型
|
static Set<String> |
getMethodValidateGroup(Method method)
获取方法上校验分组
例如:获取如下方法的校验分组信息SysAppRequest.edit.class
public ResponseData edit(@RequestBody @Validated(SysAppRequest.edit.class) SysAppRequest sysAppParam) {
...
}
|
static ParamTypeEnum |
getParamTypeEnum(Annotation[] annotations)
根据参数上的注解判断出是param参数还是request body参数
|
public static List<Annotation> getMethodFirstParamAnnotations(Method method)
注意,此方法只获取方法第一个参数的所有注解
method - 方法反射信息public static Set<String> getMethodValidateGroup(Method method)
例如:获取如下方法的校验分组信息SysAppRequest.edit.class
public ResponseData edit(@RequestBody @Validated(SysAppRequest.edit.class) SysAppRequest sysAppParam) {
...
}
method - 方法反射信息public static Type[] getMethodGenericTypes(Method method)
method - 方法反射信息public static Type getMethodReturnType(Method method)
method - 方法反射信息public static List<ParameterMetadata> getMethodParameterInfos(Method method)
public static ParamTypeEnum getParamTypeEnum(Annotation[] annotations)
Copyright © 2022. All rights reserved.