From 2ecda1d245666fb2f09d7c1581eae02e1e65484e Mon Sep 17 00:00:00 2001 From: huangchengxing <841396397@qq.com> Date: Tue, 5 Jul 2022 13:38:25 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=B7=B2=E5=90=88=E6=88=90?= =?UTF-8?q?=E6=B3=A8=E8=A7=A3=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../annotation/SynthesizedAnnotation.java | 68 +++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 hutool-core/src/main/java/cn/hutool/core/annotation/SynthesizedAnnotation.java diff --git a/hutool-core/src/main/java/cn/hutool/core/annotation/SynthesizedAnnotation.java b/hutool-core/src/main/java/cn/hutool/core/annotation/SynthesizedAnnotation.java new file mode 100644 index 000000000..5c093ee6c --- /dev/null +++ b/hutool-core/src/main/java/cn/hutool/core/annotation/SynthesizedAnnotation.java @@ -0,0 +1,68 @@ +package cn.hutool.core.annotation; + +import java.lang.annotation.Annotation; + +/** + * 表示一个处于合成状态的注解对象 + * + * @author huangchengxing + */ +public interface SynthesizedAnnotation extends Annotation { + + /** + * 获取该合成注解对应的根节点 + * + * @return 数据源 + */ + T getRoot(); + + /** + * 该合成注解是为根对象 + * + * @return 对象 + */ + default boolean isRoot() { + return getRoot() == this; + } + + /** + * 获取被合成的注解对象 + * + * @return 注解对象 + */ + Annotation getAnnotation(); + + /** + * 获取该合成注解与根对象的垂直距离。 + * 默认情况下,该距离即为当前注解与根对象之间相隔的层级数。 + * + * @return 合成注解与根对象的垂直距离 + */ + int getVerticalDistance(); + + /** + * 获取该合成注解与根对象的水平距离。 + * 默认情况下,该距离即为当前注解与根对象之间相隔的已经被扫描到的注解数。 + * + * @return 合成注解与根对象的水平距离 + */ + int getHorizontalDistance(); + + /** + * 注解是否存在该名称相同,且类型一致的属性 + * + * @param attributeName 属性名 + * @param returnType 返回值类型 + * @return 是否存在该属性 + */ + boolean hasAttribute(String attributeName, Class returnType); + + /** + * 获取属性值 + * + * @param attributeName 属性名 + * @return 属性值 + */ + Object getAttribute(String attributeName); + +}