This commit is contained in:
Looly 2024-01-02 23:32:24 +08:00
parent 028f498a04
commit 58ce12a8db
4 changed files with 14 additions and 14 deletions

View File

@ -291,15 +291,8 @@ public class AnnotationUtil {
public static ElementType[] getTargetType(final Class<? extends Annotation> annotationType) { public static ElementType[] getTargetType(final Class<? extends Annotation> annotationType) {
final Target target = annotationType.getAnnotation(Target.class); final Target target = annotationType.getAnnotation(Target.class);
if (null == target) { if (null == target) {
return new ElementType[]{ElementType.TYPE, // // 如果没有定义@target元注解则表示支持所有节点
ElementType.FIELD, // return ElementType.values();
ElementType.METHOD, //
ElementType.PARAMETER, //
ElementType.CONSTRUCTOR, //
ElementType.LOCAL_VARIABLE, //
ElementType.ANNOTATION_TYPE, //
ElementType.PACKAGE//
};
} }
return target.value(); return target.value();
} }

View File

@ -14,6 +14,7 @@ package org.dromara.hutool.core.annotation.elements;
import org.dromara.hutool.core.annotation.AnnotationUtil; import org.dromara.hutool.core.annotation.AnnotationUtil;
import org.dromara.hutool.core.collection.CollUtil; import org.dromara.hutool.core.collection.CollUtil;
import org.dromara.hutool.core.collection.set.SetUtil;
import org.dromara.hutool.core.reflect.ClassUtil; import org.dromara.hutool.core.reflect.ClassUtil;
import org.dromara.hutool.core.reflect.method.MethodUtil; import org.dromara.hutool.core.reflect.method.MethodUtil;
import org.dromara.hutool.core.text.CharSequenceUtil; import org.dromara.hutool.core.text.CharSequenceUtil;
@ -274,13 +275,13 @@ public class HierarchicalAnnotatedElements implements AnnotatedElement, Iterable
// ========================= protected ========================= // ========================= protected =========================
/** /**
* 获取当前元素及层级结构中的关联元素的映射对象 * 获取当前元素及层级结构中的关联元素的映射对象结果只读
* *
* @return 元素映射对象 * @return 元素映射对象
*/ */
protected final Set<AnnotatedElement> getElementMappings() { public final Set<AnnotatedElement> getElementMappings() {
initElementMappingsIfNecessary(); initElementMappingsIfNecessary();
return elementMappings; return SetUtil.view(this.elementMappings);
} }
/** /**

View File

@ -82,7 +82,7 @@ public class MetaAnnotatedElement<T extends AnnotationMapping<Annotation>> imple
* @param element 被注解元素 * @param element 被注解元素
* @param mappingFactory 创建{@link AnnotationMapping}的工厂方法返回值为{@code null}时将忽略该注解 * @param mappingFactory 创建{@link AnnotationMapping}的工厂方法返回值为{@code null}时将忽略该注解
*/ */
MetaAnnotatedElement(final AnnotatedElement element, final BiFunction<T, Annotation, T> mappingFactory) { public MetaAnnotatedElement(final AnnotatedElement element, final BiFunction<T, Annotation, T> mappingFactory) {
this.element = Objects.requireNonNull(element); this.element = Objects.requireNonNull(element);
this.mappingFactory = Objects.requireNonNull(mappingFactory); this.mappingFactory = Objects.requireNonNull(mappingFactory);
// 等待懒加载 // 等待懒加载

View File

@ -11,7 +11,13 @@
*/ */
/** /**
* 注解包提供增强型注解和注解工具类 * 注解包提供增强型注解和注解工具类处理包括<br>
* <ul>
* <li>注解元素AnnotatedElement上的注解</li>
* <li>父元素上的注解包括类接口方法属性</li>
* <li>注解上的注解</li>
* <li>父元素上的注解上的注解</li>
* </ul>
* *
* @author looly * @author looly
* *