Polishing

This commit is contained in:
Juergen Hoeller 2020-04-25 17:59:04 +02:00
parent 5bca18f091
commit ad088f2157
2 changed files with 5 additions and 6 deletions

View File

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2019 the original author or authors. * Copyright 2002-2020 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -173,9 +173,8 @@ final class MergedAnnotationsCollection implements MergedAnnotations {
if (!isMappingForType(mapping, requiredType)) { if (!isMappingForType(mapping, requiredType)) {
continue; continue;
} }
MergedAnnotation<A> candidate = (mappingIndex == 0 MergedAnnotation<A> candidate = (mappingIndex == 0 ? (MergedAnnotation<A>) root :
? (MergedAnnotation<A>) root TypeMappedAnnotation.createIfPossible(mapping, root, IntrospectionFailureLogger.INFO));
: TypeMappedAnnotation.createIfPossible(mapping, root, IntrospectionFailureLogger.INFO));
if (candidate != null && (predicate == null || predicate.test(candidate))) { if (candidate != null && (predicate == null || predicate.test(candidate))) {
if (selector.isBestCandidate(candidate)) { if (selector.isBestCandidate(candidate)) {
return candidate; return candidate;

View File

@ -596,8 +596,7 @@ final class TypeMappedAnnotation<A extends Annotation> extends AbstractMergedAnn
private int getAttributeIndex(String attributeName, boolean required) { private int getAttributeIndex(String attributeName, boolean required) {
Assert.hasText(attributeName, "Attribute name must not be null"); Assert.hasText(attributeName, "Attribute name must not be null");
int attributeIndex = (isFiltered(attributeName) ? -1 : int attributeIndex = (isFiltered(attributeName) ? -1 : this.mapping.getAttributes().indexOf(attributeName));
this.mapping.getAttributes().indexOf(attributeName));
if (attributeIndex == -1 && required) { if (attributeIndex == -1 && required) {
throw new NoSuchElementException("No attribute named '" + attributeName + throw new NoSuchElementException("No attribute named '" + attributeName +
"' present in merged annotation " + getType().getName()); "' present in merged annotation " + getType().getName());
@ -648,6 +647,7 @@ final class TypeMappedAnnotation<A extends Annotation> extends AbstractMergedAnn
@Nullable @Nullable
static <A extends Annotation> TypeMappedAnnotation<A> createIfPossible( static <A extends Annotation> TypeMappedAnnotation<A> createIfPossible(
AnnotationTypeMapping mapping, MergedAnnotation<?> annotation, IntrospectionFailureLogger logger) { AnnotationTypeMapping mapping, MergedAnnotation<?> annotation, IntrospectionFailureLogger logger) {
if (annotation instanceof TypeMappedAnnotation) { if (annotation instanceof TypeMappedAnnotation) {
TypeMappedAnnotation<?> typeMappedAnnotation = (TypeMappedAnnotation<?>) annotation; TypeMappedAnnotation<?> typeMappedAnnotation = (TypeMappedAnnotation<?>) annotation;
return createIfPossible(mapping, typeMappedAnnotation.source, return createIfPossible(mapping, typeMappedAnnotation.source,