diff --git a/spring-context/src/main/java/org/springframework/context/support/ApplicationListenerDetector.java b/spring-context/src/main/java/org/springframework/context/support/ApplicationListenerDetector.java index 621b26acfd..7589409bde 100644 --- a/spring-context/src/main/java/org/springframework/context/support/ApplicationListenerDetector.java +++ b/spring-context/src/main/java/org/springframework/context/support/ApplicationListenerDetector.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2022 the original author or authors. + * Copyright 2002-2023 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -114,9 +114,8 @@ class ApplicationListenerDetector implements DestructionAwareBeanPostProcessor, @Override public boolean equals(@Nullable Object other) { - return (this == other || - (other instanceof ApplicationListenerDetector applicationListenerDetector && - this.applicationContext == applicationListenerDetector.applicationContext)); + return (this == other || (other instanceof ApplicationListenerDetector that && + this.applicationContext == that.applicationContext)); } @Override diff --git a/spring-core/src/main/java/org/springframework/core/type/AnnotatedTypeMetadata.java b/spring-core/src/main/java/org/springframework/core/type/AnnotatedTypeMetadata.java index b32e552a54..f03b8fe720 100644 --- a/spring-core/src/main/java/org/springframework/core/type/AnnotatedTypeMetadata.java +++ b/spring-core/src/main/java/org/springframework/core/type/AnnotatedTypeMetadata.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2019 the original author or authors. + * Copyright 2002-2023 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -30,8 +30,8 @@ import org.springframework.util.MultiValueMap; /** * Defines access to the annotations of a specific type ({@link AnnotationMetadata class} - * or {@link MethodMetadata method}), in a form that does not necessarily require the - * class-loading. + * or {@link MethodMetadata method}), in a form that does not necessarily require + * class loading. * * @author Juergen Hoeller * @author Mark Fisher @@ -46,8 +46,8 @@ import org.springframework.util.MultiValueMap; public interface AnnotatedTypeMetadata { /** - * Return annotation details based on the direct annotations of the - * underlying element. + * Get annotation details based on the direct annotations and meta-annotations + * of the underlying element. * @return merged annotations based on the direct annotations * @since 5.2 */ @@ -58,7 +58,7 @@ public interface AnnotatedTypeMetadata { * of the given type defined. *
If this method returns {@code true}, then
* {@link #getAnnotationAttributes} will return a non-null Map.
- * @param annotationName the fully qualified class name of the annotation
+ * @param annotationName the fully-qualified class name of the annotation
* type to look for
* @return whether a matching annotation is defined
*/
@@ -70,11 +70,11 @@ public interface AnnotatedTypeMetadata {
* Retrieve the attributes of the annotation of the given type, if any (i.e. if
* defined on the underlying element, as direct annotation or meta-annotation),
* also taking attribute overrides on composed annotations into account.
- * @param annotationName the fully qualified class name of the annotation
+ * @param annotationName the fully-qualified class name of the annotation
* type to look for
- * @return a Map of attributes, with the attribute name as key (e.g. "value")
- * and the defined attribute value as Map value. This return value will be
- * {@code null} if no matching annotation is defined.
+ * @return a {@link Map} of attributes, with each annotation attribute name
+ * as map key (e.g. "location") and the attribute's value as map value; or
+ * {@code null} if no matching annotation is found
*/
@Nullable
default Map Note: this method does not take attribute overrides on composed
+ * annotations into account.
+ * @param annotationName the fully-qualified class name of the annotation
* type to look for
- * @return a MultiMap of attributes, with the attribute name as key (e.g. "value")
- * and a list of the defined attribute values as Map value. This return value will
- * be {@code null} if no matching annotation is defined.
+ * @return a {@link MultiValueMap} of attributes, with each annotation attribute
+ * name as map key (e.g. "location") and a list of the attribute's values as
+ * map value; or {@code null} if no matching annotation is found
* @see #getAllAnnotationAttributes(String, boolean)
*/
@Nullable
@@ -125,13 +126,16 @@ public interface AnnotatedTypeMetadata {
/**
* Retrieve all attributes of all annotations of the given type, if any (i.e. if
* defined on the underlying element, as direct annotation or meta-annotation).
- * Note that this variant does not take attribute overrides into account.
- * @param annotationName the fully qualified class name of the annotation
+ * Note: this method does not take attribute overrides on composed
+ * annotations into account.
+ * @param annotationName the fully-qualified class name of the annotation
* type to look for
- * @param classValuesAsString whether to convert class references to String
- * @return a MultiMap of attributes, with the attribute name as key (e.g. "value")
- * and a list of the defined attribute values as Map value. This return value will
- * be {@code null} if no matching annotation is defined.
+ * @param classValuesAsString whether to convert class references to String
+ * class names for exposure as values in the returned Map, instead of Class
+ * references which might potentially have to be loaded first
+ * @return a {@link MultiValueMap} of attributes, with each annotation attribute
+ * name as map key (e.g. "location") and a list of the attribute's values as
+ * map value; or {@code null} if no matching annotation is found
* @see #getAllAnnotationAttributes(String)
*/
@Nullable
@@ -142,8 +146,8 @@ public interface AnnotatedTypeMetadata {
return getAnnotations().stream(annotationName)
.filter(MergedAnnotationPredicates.unique(MergedAnnotation::getMetaTypes))
.map(MergedAnnotation::withNonMergedAttributes)
- .collect(MergedAnnotationCollectors.toMultiValueMap(map ->
- map.isEmpty() ? null : map, adaptations));
+ .collect(MergedAnnotationCollectors.toMultiValueMap(
+ map -> (map.isEmpty() ? null : map), adaptations));
}
}