From 9cd03139354986eec50853ad0e068fd97fa34014 Mon Sep 17 00:00:00 2001 From: Looly Date: Sun, 7 May 2023 21:18:21 +0800 Subject: [PATCH] fix code --- .../hutool/core/annotation/AnnotationMappingProxy.java | 6 +++--- .../hutool/core/annotation/MetaAnnotatedElement.java | 7 ++++--- .../core/annotation/RepeatableMetaAnnotatedElement.java | 5 +++-- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/hutool-core/src/main/java/org/dromara/hutool/core/annotation/AnnotationMappingProxy.java b/hutool-core/src/main/java/org/dromara/hutool/core/annotation/AnnotationMappingProxy.java index 28ece18d3..3c5600975 100644 --- a/hutool-core/src/main/java/org/dromara/hutool/core/annotation/AnnotationMappingProxy.java +++ b/hutool-core/src/main/java/org/dromara/hutool/core/annotation/AnnotationMappingProxy.java @@ -90,7 +90,7 @@ public final class AnnotationMappingProxy implements Invoc * @param annotation 属性映射 */ private AnnotationMappingProxy(final AnnotationMapping annotation) { - int methodCount = annotation.getAttributes().length; + final int methodCount = annotation.getAttributes().length; this.methods = new HashMap<>(methodCount + 5); this.valueCache = new SafeConcurrentHashMap<>(methodCount); this.mapping = annotation; @@ -123,7 +123,7 @@ public final class AnnotationMappingProxy implements Invoc methods.put("hashCode", (method, args) -> proxyHashCode()); methods.put("annotationType", (method, args) -> proxyAnnotationType()); methods.put("getMapping", (method, args) -> proxyGetMapping()); - for (Method attribute : mapping.getAttributes()) { + for (final Method attribute : mapping.getAttributes()) { methods.put(attribute.getName(), (method, args) -> getAttributeValue(method.getName(), method.getReturnType())); } } @@ -148,7 +148,7 @@ public final class AnnotationMappingProxy implements Invoc /** * 代理{@link Annotation#equals(Object)}方法 */ - private boolean proxyEquals(Object o) { + private boolean proxyEquals(final Object o) { return Objects.equals(mapping, o); } diff --git a/hutool-core/src/main/java/org/dromara/hutool/core/annotation/MetaAnnotatedElement.java b/hutool-core/src/main/java/org/dromara/hutool/core/annotation/MetaAnnotatedElement.java index aff4e837b..da1e39ca2 100644 --- a/hutool-core/src/main/java/org/dromara/hutool/core/annotation/MetaAnnotatedElement.java +++ b/hutool-core/src/main/java/org/dromara/hutool/core/annotation/MetaAnnotatedElement.java @@ -41,6 +41,7 @@ import java.util.function.BiFunction; * @author huangchengxing * @see ResolvedAnnotationMapping * @since 6.0.0 + * @param AnnotationMapping类型 */ public class MetaAnnotatedElement> implements AnnotatedElement, Iterable { @@ -124,7 +125,7 @@ public class MetaAnnotatedElement> imple * @return 是否 */ @Override - public boolean isAnnotationPresent(Class annotationType) { + public boolean isAnnotationPresent(final Class annotationType) { return getMapping(annotationType) .isPresent(); } @@ -299,7 +300,7 @@ public class MetaAnnotatedElement> imple if (Objects.isNull(annotationMappings)) { synchronized (this) { if (Objects.isNull(annotationMappings)) { - Map, T> mappings = new LinkedHashMap<>(8); + final Map, T> mappings = new LinkedHashMap<>(8); initAnnotationMappings(mappings); this.annotationMappings = Collections.unmodifiableMap(mappings); } @@ -319,7 +320,7 @@ public class MetaAnnotatedElement> imple .forEach(deque::addLast); while (!deque.isEmpty()) { // 若已有该类型的注解,则不再进行扫描 - T mapping = deque.removeFirst(); + final T mapping = deque.removeFirst(); if (!isNeedMapping(mappings, mapping)) { continue; } diff --git a/hutool-core/src/main/java/org/dromara/hutool/core/annotation/RepeatableMetaAnnotatedElement.java b/hutool-core/src/main/java/org/dromara/hutool/core/annotation/RepeatableMetaAnnotatedElement.java index 031115880..97c1140ea 100644 --- a/hutool-core/src/main/java/org/dromara/hutool/core/annotation/RepeatableMetaAnnotatedElement.java +++ b/hutool-core/src/main/java/org/dromara/hutool/core/annotation/RepeatableMetaAnnotatedElement.java @@ -46,6 +46,7 @@ import java.util.stream.Collectors; * @author huangchengxing * @since 6.0.0 * @see RepeatableAnnotationCollector + * @param AnnotationMapping类型 */ public class RepeatableMetaAnnotatedElement> implements AnnotatedElement, Iterable { @@ -282,9 +283,9 @@ public class RepeatableMetaAnnotatedElement initAggregations(final AnnotatedElement element) { // TODO 若有可能,一并支持处理元注解中的可重复注解 - List result = new ArrayList<>(); + final List result = new ArrayList<>(); for (final Annotation declaredAnnotation : AnnotationUtil.getDeclaredAnnotations(element)) { - List repeatableAnnotations = collectRepeatable(declaredAnnotation); + final List repeatableAnnotations = collectRepeatable(declaredAnnotation); if (CollUtil.isNotEmpty(repeatableAnnotations)) { result.addAll(repeatableAnnotations); }