Skip to content

Commit 6e08c56

Browse files
committed
Improve Javadoc for RepeatableContainers
1 parent fb6d3f5 commit 6e08c56

File tree

1 file changed

+14
-12
lines changed

1 file changed

+14
-12
lines changed

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

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,12 @@ private RepeatableContainers(@Nullable RepeatableContainers parent) {
5353

5454

5555
/**
56-
* Add an additional explicit relationship between a contained and
56+
* Add an additional explicit relationship between a container and
5757
* repeatable annotation.
58-
* @param container the container type
59-
* @param repeatable the contained repeatable type
58+
* <p>WARNING: the arguments supplied to this method are in the reverse order
59+
* of those supplied to {@link #of(Class, Class)}.
60+
* @param container the container annotation type
61+
* @param repeatable the repeatable annotation type
6062
* @return a new {@link RepeatableContainers} instance
6163
*/
6264
public RepeatableContainers and(Class<? extends Annotation> container,
@@ -103,7 +105,9 @@ public static RepeatableContainers standardRepeatables() {
103105
/**
104106
* Create a {@link RepeatableContainers} instance that uses predefined
105107
* repeatable and container types.
106-
* @param repeatable the contained repeatable annotation type
108+
* <p>WARNING: the arguments supplied to this method are in the reverse order
109+
* of those supplied to {@link #and(Class, Class)}.
110+
* @param repeatable the repeatable annotation type
107111
* @param container the container annotation type or {@code null}. If specified,
108112
* this annotation must declare a {@code value} attribute returning an array
109113
* of repeatable annotations. If not specified, the container will be
@@ -122,7 +126,7 @@ public static RepeatableContainers of(
122126
}
123127

124128
/**
125-
* Create a {@link RepeatableContainers} instance that does not expand any
129+
* Create a {@link RepeatableContainers} instance that does not support any
126130
* repeatable annotations.
127131
* @return a {@link RepeatableContainers} instance
128132
*/
@@ -208,20 +212,18 @@ private static class ExplicitRepeatableContainer extends RepeatableContainers {
208212
}
209213
Class<?> returnType = valueMethod.getReturnType();
210214
if (!returnType.isArray() || returnType.getComponentType() != repeatable) {
211-
throw new AnnotationConfigurationException("Container type [" +
212-
container.getName() +
213-
"] must declare a 'value' attribute for an array of type [" +
214-
repeatable.getName() + "]");
215+
throw new AnnotationConfigurationException(
216+
"Container type [%s] must declare a 'value' attribute for an array of type [%s]"
217+
.formatted(container.getName(), repeatable.getName()));
215218
}
216219
}
217220
catch (AnnotationConfigurationException ex) {
218221
throw ex;
219222
}
220223
catch (Throwable ex) {
221224
throw new AnnotationConfigurationException(
222-
"Invalid declaration of container type [" + container.getName() +
223-
"] for repeatable annotation [" + repeatable.getName() + "]",
224-
ex);
225+
"Invalid declaration of container type [%s] for repeatable annotation [%s]"
226+
.formatted(container.getName(), repeatable.getName()), ex);
225227
}
226228
this.repeatable = repeatable;
227229
this.container = container;

0 commit comments

Comments
 (0)