public final class ReflectionUtil extends Object
| 限定符和类型 | 方法和说明 |
|---|---|
static Map<String,Object> |
invokeToJsonObjectMethod(Object target,
Method toJsonObjectMethod)
调用
com.nimbusds.jose 下相关类的 toJSONObject() 方法. |
static void |
registerController(String controllerBeanName,
org.springframework.context.support.GenericApplicationContext applicationContext,
Class<?> clz)
在 mvc 中做 Uri 映射等动作
|
static void |
setFieldValue(String fieldName,
Object fieldValue,
Object targetObject,
Class<?> targetClass)
反射设置字段值
|
static void |
setRequestMappingUri(String methodName,
String requestMappingUri,
Class<?> clz,
Class<?>... parameterTypes)
给 targetClass 的 methodName 方法上的 @RequestMapping 的 value 重新赋值为 requestMappingUri
|
@NonNull public static Map<String,Object> invokeToJsonObjectMethod(@NonNull Object target, @Nullable Method toJsonObjectMethod) throws IllegalAccessException, InvocationTargetException
com.nimbusds.jose 下相关类的 toJSONObject() 方法. target - 目标对象toJsonObjectMethod - 目标方法(toJSONObject)IllegalAccessException - 调用异常InvocationTargetException - 调用异常public static void setFieldValue(@NonNull
String fieldName,
@NonNull
Object fieldValue,
@Nullable
Object targetObject,
@NonNull
Class<?> targetClass)
throws NoSuchFieldException,
IllegalAccessException
fieldName - 字段名称fieldValue - 要设置的字段值targetObject - 目标对象, 设置静态字段时为 null 值targetClass - 目标的 ClassNoSuchFieldException - 反射异常IllegalAccessException - 反射异常public static void registerController(@NonNull
String controllerBeanName,
@NonNull
org.springframework.context.support.GenericApplicationContext applicationContext,
@Nullable
Class<?> clz)
throws Exception
controllerBeanName - 在 IOC 容器中注册的 controllerBeanNameapplicationContext - applicationContextclz - controllerBeanName 的 class, 可以是父类的 class, 可以为 nullException - Exceptionpublic static void setRequestMappingUri(@NonNull
String methodName,
@NonNull
String requestMappingUri,
@NonNull
Class<?> clz,
Class<?>... parameterTypes)
throws Exception
methodName - method namerequestMappingUri - request mapping uriclz - method 的 classparameterTypes - the parameter arrayException - ExceptionCopyright © 2021. All rights reserved.