Skip to content

Commit d82e70e

Browse files
committed
Cross reference annotation search APIs in Javadoc
Closes gh-34421
1 parent 1109892 commit d82e70e

File tree

4 files changed

+35
-19
lines changed

4 files changed

+35
-19
lines changed

spring-core/src/main/java/org/springframework/core/annotation/AnnotatedElementUtils.java

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2022 the original author or authors.
2+
* Copyright 2002-2025 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -36,8 +36,12 @@
3636
*
3737
* <p>{@code AnnotatedElementUtils} defines the public API for Spring's
3838
* meta-annotation programming model with support for <em>annotation attribute
39-
* overrides</em>. If you do not need support for annotation attribute
40-
* overrides, consider using {@link AnnotationUtils} instead.
39+
* overrides</em> and {@link AliasFor @AliasFor}. Note, however, that
40+
* {@code AnnotatedElementUtils} is effectively a facade for the
41+
* {@link MergedAnnotations} API. For fine-grained support consider using the
42+
* {@code MergedAnnotations} API directly. If you do not need support for
43+
* annotation attribute overrides, {@code @AliasFor}, or merged annotations,
44+
* consider using {@link AnnotationUtils} instead.
4145
*
4246
* <p>Note that the features of this class are not provided by the JDK's
4347
* introspection facilities themselves.
@@ -87,6 +91,7 @@
8791
* @since 4.0
8892
* @see AliasFor
8993
* @see AnnotationAttributes
94+
* @see MergedAnnotations
9095
* @see AnnotationUtils
9196
* @see BridgeMethodResolver
9297
*/

spring-core/src/main/java/org/springframework/core/annotation/AnnotationUtils.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2024 the original author or authors.
2+
* Copyright 2002-2025 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -60,7 +60,7 @@
6060
* <h3>Terminology</h3>
6161
* The terms <em>directly present</em>, <em>indirectly present</em>, and
6262
* <em>present</em> have the same meanings as defined in the class-level
63-
* javadoc for {@link AnnotatedElement} (in Java 8).
63+
* javadoc for {@link AnnotatedElement}.
6464
*
6565
* <p>An annotation is <em>meta-present</em> on an element if the annotation
6666
* is declared as a meta-annotation on some other annotation which is
@@ -73,7 +73,8 @@
7373
* provide support for finding annotations used as meta-annotations. Consult the
7474
* javadoc for each method in this class for details. For fine-grained support for
7575
* meta-annotations with <em>attribute overrides</em> in <em>composed annotations</em>,
76-
* consider using {@link AnnotatedElementUtils}'s more specific methods instead.
76+
* consider using the {@link MergedAnnotations} API directly or the more specific
77+
* methods in {@link AnnotatedElementUtils} instead.
7778
*
7879
* <h3>Attribute Aliases</h3>
7980
* <p>All public methods in this class that return annotations, arrays of
@@ -97,6 +98,7 @@
9798
* @since 2.0
9899
* @see AliasFor
99100
* @see AnnotationAttributes
101+
* @see MergedAnnotations
100102
* @see AnnotatedElementUtils
101103
* @see BridgeMethodResolver
102104
* @see java.lang.reflect.AnnotatedElement#getAnnotations()

spring-core/src/main/java/org/springframework/core/annotation/MergedAnnotations.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2023 the original author or authors.
2+
* Copyright 2002-2025 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -37,7 +37,7 @@
3737
* <ul>
3838
* <li>Explicit and Implicit {@link AliasFor @AliasFor} declarations on one or
3939
* more attributes within the annotation</li>
40-
* <li>Explicit {@link AliasFor @AliasFor} declarations for a meta-annotation</li>
40+
* <li>Explicit {@code @AliasFor} declarations for a meta-annotation</li>
4141
* <li>Convention based attribute aliases for a meta-annotation</li>
4242
* <li>From a meta-annotation declaration</li>
4343
* </ul>
@@ -140,6 +140,9 @@
140140
* @see MergedAnnotationCollectors
141141
* @see MergedAnnotationPredicates
142142
* @see MergedAnnotationSelectors
143+
* @see AliasFor
144+
* @see AnnotationUtils
145+
* @see AnnotatedElementUtils
143146
*/
144147
public interface MergedAnnotations extends Iterable<MergedAnnotation<Annotation>> {
145148

@@ -560,6 +563,7 @@ private Search(SearchStrategy searchStrategy) {
560563
* @see #withRepeatableContainers(RepeatableContainers)
561564
* @see #withAnnotationFilter(AnnotationFilter)
562565
* @see #from(AnnotatedElement)
566+
* @see org.springframework.test.context.TestContextAnnotationUtils#searchEnclosingClass(Class)
563567
*/
564568
public Search withEnclosingClasses(Predicate<Class<?>> searchEnclosingClass) {
565569
Assert.notNull(searchEnclosingClass, "Predicate must not be null");

spring-test/src/main/java/org/springframework/test/context/TestContextAnnotationUtils.java

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2024 the original author or authors.
2+
* Copyright 2002-2025 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -43,19 +43,20 @@
4343

4444
/**
4545
* {@code TestContextAnnotationUtils} is a collection of utility methods that
46-
* complements the standard support already available in {@link AnnotationUtils}
47-
* and {@link AnnotatedElementUtils}, while transparently honoring
48-
* {@link NestedTestConfiguration @NestedTestConfiguration} semantics.
46+
* complements the standard support already available in {@link MergedAnnotations},
47+
* {@link AnnotationUtils}, and {@link AnnotatedElementUtils}, while transparently
48+
* honoring {@link NestedTestConfiguration @NestedTestConfiguration} semantics.
4949
*
5050
* <p>Mainly for internal use within the <em>Spring TestContext Framework</em>
5151
* but also supported for third-party integrations with the TestContext framework.
5252
*
53-
* <p>Whereas {@code AnnotationUtils} and {@code AnnotatedElementUtils} provide
54-
* utilities for <em>getting</em> or <em>finding</em> annotations,
55-
* {@code TestContextAnnotationUtils} goes a step further by providing support
56-
* for determining the <em>root class</em> on which an annotation is declared,
57-
* either directly or indirectly via a <em>composed annotation</em>. This
58-
* additional information is encapsulated in an {@link AnnotationDescriptor}.
53+
* <p>Whereas {@code MergedAnnotations}, {@code AnnotationUtils} and
54+
* {@code AnnotatedElementUtils} provide utilities for <em>getting</em> or
55+
* <em>finding</em> annotations, {@code TestContextAnnotationUtils} goes a step
56+
* further by providing support for determining the <em>root class</em> on which
57+
* an annotation is declared, either directly or indirectly via a
58+
* <em>composed annotation</em>. This additional information is encapsulated in
59+
* an {@link AnnotationDescriptor}.
5960
*
6061
* <p>The additional information provided by an {@code AnnotationDescriptor} is
6162
* required by the <em>Spring TestContext Framework</em> in order to be able to
@@ -67,7 +68,11 @@
6768
* example, {@link ContextConfiguration#inheritLocations}.
6869
*
6970
* @author Sam Brannen
70-
* @since 5.3, though originally since 4.0 as {@code org.springframework.test.util.MetaAnnotationUtils}
71+
* @since 5.3
72+
* @see MergedAnnotations
73+
* @see MergedAnnotations.Search
74+
* @see MergedAnnotations.Search#withEnclosingClasses(Predicate)
75+
* @see #searchEnclosingClass(Class)
7176
* @see AnnotationUtils
7277
* @see AnnotatedElementUtils
7378
* @see AnnotationDescriptor

0 commit comments

Comments
 (0)