mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-05-09 23:51:34 +08:00
add mathod
This commit is contained in:
parent
eb38b6b3ff
commit
c11e2a935f
@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
-------------------------------------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
# 5.5.2 (2020-11-20)
|
# 5.5.2 (2020-11-25)
|
||||||
|
|
||||||
### 新特性
|
### 新特性
|
||||||
* 【crypto 】 KeyUtil增加重载,AES构造增加重载(issue#I25NNZ@Gitee)
|
* 【crypto 】 KeyUtil增加重载,AES构造增加重载(issue#I25NNZ@Gitee)
|
||||||
@ -12,6 +12,7 @@
|
|||||||
* 【extra 】 新增Rhino表达式执行引擎(pr#1229@Github)
|
* 【extra 】 新增Rhino表达式执行引擎(pr#1229@Github)
|
||||||
* 【crypto 】 增加判空(issue#1230@Github)
|
* 【crypto 】 增加判空(issue#1230@Github)
|
||||||
* 【core 】 xml.setXmlStandalone(true)格式优化(pr#1234@Github)
|
* 【core 】 xml.setXmlStandalone(true)格式优化(pr#1234@Github)
|
||||||
|
* 【core 】 AnnotationUtil增加setValue方法(pr#1250@Github)
|
||||||
|
|
||||||
### Bug修复
|
### Bug修复
|
||||||
* 【cron 】 修复CronTimer可能死循环的问题(issue#1224@Github)
|
* 【cron 】 修复CronTimer可能死循环的问题(issue#1224@Github)
|
||||||
|
@ -12,8 +12,6 @@ import java.lang.annotation.Retention;
|
|||||||
import java.lang.annotation.RetentionPolicy;
|
import java.lang.annotation.RetentionPolicy;
|
||||||
import java.lang.annotation.Target;
|
import java.lang.annotation.Target;
|
||||||
import java.lang.reflect.AnnotatedElement;
|
import java.lang.reflect.AnnotatedElement;
|
||||||
import java.lang.reflect.Field;
|
|
||||||
import java.lang.reflect.InvocationHandler;
|
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.lang.reflect.Proxy;
|
import java.lang.reflect.Proxy;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
@ -205,20 +203,16 @@ public class AnnotationUtil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 刷新注解的属性值
|
* 设置新的注解的属性(字段)值
|
||||||
|
*
|
||||||
* @param annotation 注解对象
|
* @param annotation 注解对象
|
||||||
* @param annotationField 注解属性名称
|
* @param annotationField 注解属性(字段)名称
|
||||||
* @param value 要更新的属性值
|
* @param value 要更新的属性值
|
||||||
* @throws Exception 可能出现的异常(一般情况下不会发生)
|
* @since 5.5.2
|
||||||
*/
|
*/
|
||||||
public static void refreshAnnotationValue(Annotation annotation, String annotationField, Object value) throws Exception {
|
@SuppressWarnings({"rawtypes", "unchecked"})
|
||||||
InvocationHandler invocationHandler = Proxy.getInvocationHandler(annotation);
|
public static void setValue(Annotation annotation, String annotationField, Object value) {
|
||||||
Field field = invocationHandler.getClass().getDeclaredField("memberValues");
|
final Map memberValues = (Map) ReflectUtil.getFieldValue(Proxy.getInvocationHandler(annotation), "memberValues");
|
||||||
boolean accessible = field.isAccessible();
|
|
||||||
field.setAccessible(true);
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
Map<Object, Object> memberValues = (Map<Object, Object>) field.get(invocationHandler);
|
|
||||||
memberValues.put(annotationField, value);
|
memberValues.put(annotationField, value);
|
||||||
field.setAccessible(accessible);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user