fix comment

This commit is contained in:
huangchengxing 2022-07-05 16:53:58 +08:00
parent c343b51e38
commit 749ecb0e7d
4 changed files with 27 additions and 8 deletions

View File

@ -3,23 +3,24 @@ package cn.hutool.core.annotation;
import java.lang.annotation.Annotation;
/**
* 表示一个处于合成状态的注解对象
* 用于在{@link SyntheticAnnotation}表示一个处于合成状态的注解对象
*
* @author huangchengxing
* @see SyntheticAnnotation
*/
public interface SynthesizedAnnotation extends Annotation {
/**
* 获取该合成注解对应的根节点
*
* @return 数据源
* @return 合成注解对应的根节点
*/
Object getRoot();
/**
* 该合成注解是为根对象
*
* @return 对象
* @return 对象
*/
default boolean isRoot() {
return getRoot() == this;

View File

@ -3,7 +3,7 @@ package cn.hutool.core.annotation;
import java.util.Collection;
/**
* 合成注解属性选择器用于中合成注解中从指定类型的注解里获取到对应的属性值
* 合成注解属性选择器用于{@link SyntheticAnnotation}中从指定类型的合成注解里获取到对应的属性值
*
* @author huangchengxing
*/

View File

@ -4,9 +4,27 @@ import java.lang.annotation.Annotation;
import java.lang.reflect.AnnotatedElement;
/**
* 表示基于特定规则聚合的一组注解
* 表示基于特定规则聚合的一组注解对象
*
* <p>合成注解一般被用于处理类层级结果中具有直接或间接关联的注解对象
* 当实例被创建时会获取到这些注解对象并使用{@link SynthesizedAnnotationSelector}对类型相同的注解进行过滤
* 并最终得到类型不重复的有效注解对象这些有效注解将被包装为{@link SynthesizedAnnotation}
* 然后最终用于合成一个{@link SynthesizedAnnotation}
*
* <p>合成注解可以作为一个特殊的{@link Annotation}或者{@link AnnotatedElement}
* 当调用{@link Annotation}的方法时应当返回当前实例本身的有效信息
* 而当调用{@link AnnotatedElement}的方法时应当返回用于合成该对象的相关注解的信息
*
* <p>合成注解允许通过{@link #syntheticAnnotation(Class)}合成一个指定的注解对象
* 该方法返回的注解对象可能是原始的注解对象也有可能通过动态代理的方式生成
* 该对象实例的属性不一定来自对象本身而是来自于经过{@link SynthesizedAnnotationAttributeProcessor}
* 处理后的用于合成当前实例的全部关联注解的相关属性
*
* @author huangchengxing
* @see SynthesizedAnnotation
* @see SynthesizedAnnotationSelector
* @see SynthesizedAnnotationAttributeProcessor
* @see SyntheticMetaAnnotation
*/
public interface SyntheticAnnotation extends Annotation, AnnotatedElement {

View File

@ -86,7 +86,7 @@ class SyntheticAnnotationProxy implements InvocationHandler {
methods.put("hasAttribute", (method, args) -> annotation.hasAttribute((String)args[0], (Class<?>)args[1]));
methods.put("getAttribute", (method, args) -> annotation.getAttribute((String)args[0]));
methods.put("annotationType", (method, args) -> annotation.annotationType());
for (Method declaredMethod : annotation.getAnnotation().annotationType().getDeclaredMethods()) {
for (final Method declaredMethod : annotation.getAnnotation().annotationType().getDeclaredMethods()) {
methods.put(declaredMethod.getName(), (method, args) -> proxyAttributeValue(method));
}
}