Skip to content

Commit a33b143

Browse files
committed
Polishing annotation processing internals
1 parent 2ede74f commit a33b143

File tree

2 files changed

+14
-18
lines changed

2 files changed

+14
-18
lines changed

spring-context/src/main/java/org/springframework/context/annotation/AnnotationConfigUtils.java

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
package org.springframework.context.annotation;
1818

19+
import java.lang.annotation.Annotation;
1920
import java.util.Collections;
2021
import java.util.LinkedHashSet;
2122
import java.util.Map;
@@ -271,32 +272,26 @@ static BeanDefinitionHolder applyScopedProxyMode(
271272
}
272273

273274
@Nullable
274-
static AnnotationAttributes attributesFor(AnnotatedTypeMetadata metadata, Class<?> annotationClass) {
275-
return attributesFor(metadata, annotationClass.getName());
275+
static AnnotationAttributes attributesFor(AnnotatedTypeMetadata metadata, Class<?> annotationType) {
276+
return attributesFor(metadata, annotationType.getName());
276277
}
277278

278279
@Nullable
279-
static AnnotationAttributes attributesFor(AnnotatedTypeMetadata metadata, String annotationClassName) {
280-
return AnnotationAttributes.fromMap(metadata.getAnnotationAttributes(annotationClassName));
281-
}
282-
283-
static Set<AnnotationAttributes> attributesForRepeatable(AnnotationMetadata metadata,
284-
Class<?> containerClass, Class<?> annotationClass) {
285-
286-
return attributesForRepeatable(metadata, containerClass.getName(), annotationClass.getName());
280+
static AnnotationAttributes attributesFor(AnnotatedTypeMetadata metadata, String annotationTypeName) {
281+
return AnnotationAttributes.fromMap(metadata.getAnnotationAttributes(annotationTypeName));
287282
}
288283

289284
@SuppressWarnings("unchecked")
290-
static Set<AnnotationAttributes> attributesForRepeatable(
291-
AnnotationMetadata metadata, String containerClassName, String annotationClassName) {
285+
static Set<AnnotationAttributes> attributesForRepeatable(AnnotationMetadata metadata,
286+
Class<? extends Annotation> containerType, Class<? extends Annotation> annotationType) {
292287

293288
Set<AnnotationAttributes> result = new LinkedHashSet<>();
294289

295-
// Direct annotation present?
296-
addAttributesIfNotNull(result, metadata.getAnnotationAttributes(annotationClassName));
290+
// Direct annotation present or meta-present?
291+
addAttributesIfNotNull(result, metadata.getAnnotationAttributes(annotationType.getName()));
297292

298-
// Container annotation present?
299-
Map<String, Object> container = metadata.getAnnotationAttributes(containerClassName);
293+
// Container annotation present or meta-present?
294+
Map<String, Object> container = metadata.getAnnotationAttributes(containerType.getName());
300295
if (container != null && container.containsKey("value")) {
301296
for (Map<String, Object> containedAttributes : (Map<String, Object>[]) container.get("value")) {
302297
addAttributesIfNotNull(result, containedAttributes);

spring-core/src/main/java/org/springframework/core/type/AnnotatedTypeMetadata.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@
3131
/**
3232
* Defines access to the annotations of a specific type ({@link AnnotationMetadata class}
3333
* or {@link MethodMetadata method}), in a form that does not necessarily require
34-
* class loading.
34+
* class loading of the types being inspected. Note, however, that classes for
35+
* encountered annotations will be loaded.
3536
*
3637
* @author Juergen Hoeller
3738
* @author Mark Fisher
@@ -48,7 +49,7 @@ public interface AnnotatedTypeMetadata {
4849
/**
4950
* Get annotation details based on the direct annotations and meta-annotations
5051
* of the underlying element.
51-
* @return merged annotations based on the direct annotations
52+
* @return merged annotations based on the direct annotations and meta-annotations
5253
* @since 5.2
5354
*/
5455
MergedAnnotations getAnnotations();

0 commit comments

Comments
 (0)