This commit is contained in:
Looly 2023-05-07 21:18:21 +08:00
parent 8a9cce4f55
commit 9cd0313935
3 changed files with 10 additions and 8 deletions

View File

@ -90,7 +90,7 @@ public final class AnnotationMappingProxy<T extends Annotation> implements Invoc
* @param annotation 属性映射
*/
private AnnotationMappingProxy(final AnnotationMapping<T> 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<T extends Annotation> 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<T extends Annotation> implements Invoc
/**
* 代理{@link Annotation#equals(Object)}方法
*/
private boolean proxyEquals(Object o) {
private boolean proxyEquals(final Object o) {
return Objects.equals(mapping, o);
}

View File

@ -41,6 +41,7 @@ import java.util.function.BiFunction;
* @author huangchengxing
* @see ResolvedAnnotationMapping
* @since 6.0.0
* @param <T> AnnotationMapping类型
*/
public class MetaAnnotatedElement<T extends AnnotationMapping<Annotation>> implements AnnotatedElement, Iterable<T> {
@ -124,7 +125,7 @@ public class MetaAnnotatedElement<T extends AnnotationMapping<Annotation>> imple
* @return 是否
*/
@Override
public boolean isAnnotationPresent(Class<? extends Annotation> annotationType) {
public boolean isAnnotationPresent(final Class<? extends Annotation> annotationType) {
return getMapping(annotationType)
.isPresent();
}
@ -299,7 +300,7 @@ public class MetaAnnotatedElement<T extends AnnotationMapping<Annotation>> imple
if (Objects.isNull(annotationMappings)) {
synchronized (this) {
if (Objects.isNull(annotationMappings)) {
Map<Class<? extends Annotation>, T> mappings = new LinkedHashMap<>(8);
final Map<Class<? extends Annotation>, T> mappings = new LinkedHashMap<>(8);
initAnnotationMappings(mappings);
this.annotationMappings = Collections.unmodifiableMap(mappings);
}
@ -319,7 +320,7 @@ public class MetaAnnotatedElement<T extends AnnotationMapping<Annotation>> imple
.forEach(deque::addLast);
while (!deque.isEmpty()) {
// 若已有该类型的注解则不再进行扫描
T mapping = deque.removeFirst();
final T mapping = deque.removeFirst();
if (!isNeedMapping(mappings, mapping)) {
continue;
}

View File

@ -46,6 +46,7 @@ import java.util.stream.Collectors;
* @author huangchengxing
* @since 6.0.0
* @see RepeatableAnnotationCollector
* @param <T> AnnotationMapping类型
*/
public class RepeatableMetaAnnotatedElement<T extends AnnotationMapping<Annotation>> implements AnnotatedElement, Iterable<T> {
@ -282,9 +283,9 @@ public class RepeatableMetaAnnotatedElement<T extends AnnotationMapping<Annotati
*/
private List<Aggregation> initAggregations(final AnnotatedElement element) {
// TODO 若有可能一并支持处理元注解中的可重复注解
List<Aggregation> result = new ArrayList<>();
final List<Aggregation> result = new ArrayList<>();
for (final Annotation declaredAnnotation : AnnotationUtil.getDeclaredAnnotations(element)) {
List<Aggregation> repeatableAnnotations = collectRepeatable(declaredAnnotation);
final List<Aggregation> repeatableAnnotations = collectRepeatable(declaredAnnotation);
if (CollUtil.isNotEmpty(repeatableAnnotations)) {
result.addAll(repeatableAnnotations);
}