Class RepeatableContainers
RepeatableContainers.standardRepeatables()
provides a default strategy that respects Java's @Repeatable
support and is suitable for most situations.
If you need to register repeatable annotation types that do not make use of
@Repeatable, you should typically use standardRepeatables()
combined with plus(Class, Class). Note that multiple invocations of
plus() can be chained together to register multiple repeatable/container
type pairs. For example:
RepeatableContainers repeatableContainers =
RepeatableContainers.standardRepeatables()
.plus(MyRepeatable1.class, MyContainer1.class)
.plus(MyRepeatable2.class, MyContainer2.class);
For special use cases where you are certain that you do not need Java's
@Repeatable support, you can use RepeatableContainers.explicitRepeatable() to create an instance of
RepeatableContainers that only supports explicit repeatable/container
type pairs. As with standardRepeatables(), plus() can be used
to register additional repeatable/container type pairs. For example:
RepeatableContainers repeatableContainers =
RepeatableContainers.explicitRepeatable(MyRepeatable1.class, MyContainer1.class)
.plus(MyRepeatable2.class, MyContainer2.class);
To completely disable repeatable annotation support use
RepeatableContainers.none().
- Since:
- 5.2
- Author:
- Phillip Webb, Sam Brannen
-
Method Summary
Modifier and TypeMethodDescriptionand(Class<? extends Annotation> container, Class<? extends Annotation> repeatable) Deprecated.booleanstatic RepeatableContainersexplicitRepeatable(Class<? extends Annotation> repeatable, @Nullable Class<? extends Annotation> container) Create aRepeatableContainersinstance that searches for repeated annotations by taking into account the supplied repeatable and container annotation types.inthashCode()static RepeatableContainersnone()Create aRepeatableContainersinstance that does not support any repeatable annotations.static RepeatableContainersof(Class<? extends Annotation> repeatable, @Nullable Class<? extends Annotation> container) Deprecated.as of Spring Framework 7.0, in favor ofexplicitRepeatable(Class, Class)final RepeatableContainersplus(Class<? extends Annotation> repeatable, Class<? extends Annotation> container) Register a pair of repeatable and container annotation types.static RepeatableContainersCreate aRepeatableContainersinstance that searches for repeated annotations according to the semantics of Java's@Repeatableannotation.
-
Method Details
-
plus
public final RepeatableContainers plus(Class<? extends Annotation> repeatable, Class<? extends Annotation> container) Register a pair of repeatable and container annotation types.See the class-level javadoc for examples.
- Parameters:
repeatable- the repeatable annotation typecontainer- the container annotation type- Returns:
- a new
RepeatableContainersinstance that is chained to the current instance - Since:
- 7.0
-
and
@Deprecated(since="7.0") public RepeatableContainers and(Class<? extends Annotation> container, Class<? extends Annotation> repeatable) Deprecated.as of Spring Framework 7.0, in favor ofplus(Class, Class)Register a pair of container and repeatable annotation types.WARNING: The arguments supplied to this method are in the reverse order of those supplied to
plus(Class, Class),explicitRepeatable(Class, Class), andof(Class, Class).- Parameters:
container- the container annotation typerepeatable- the repeatable annotation type- Returns:
- a new
RepeatableContainersinstance that is chained to the current instance
-
equals
-
hashCode
-
standardRepeatables
Create aRepeatableContainersinstance that searches for repeated annotations according to the semantics of Java's@Repeatableannotation.See the class-level javadoc for examples.
- Returns:
- a
RepeatableContainersinstance that supports@Repeatable - See Also:
-
explicitRepeatable
public static RepeatableContainers explicitRepeatable(Class<? extends Annotation> repeatable, @Nullable Class<? extends Annotation> container) Create aRepeatableContainersinstance that searches for repeated annotations by taking into account the supplied repeatable and container annotation types.WARNING: The
RepeatableContainersinstance returned by this factory method does not respect Java's@Repeatablesupport. UsestandardRepeatables()for standard@Repeatablesupport, optionally combined withplus(Class, Class).If the supplied container annotation type is not
null, it must declare avalueattribute returning an array of repeatable annotations. If the supplied container annotation type isnull, the container will be deduced by inspecting the@Repeatableannotation on therepeatableannotation type.See the class-level javadoc for examples.
- Parameters:
repeatable- the repeatable annotation typecontainer- the container annotation type ornull- Returns:
- a
RepeatableContainersinstance that does not support@Repeatable - Throws:
IllegalArgumentException- if the supplied container type isnulland the annotation type is not a repeatable annotationAnnotationConfigurationException- if the supplied container type is not a properly configured container for a repeatable annotation- Since:
- 7.0
- See Also:
-
of
@Deprecated(since="7.0") public static RepeatableContainers of(Class<? extends Annotation> repeatable, @Nullable Class<? extends Annotation> container) Deprecated.as of Spring Framework 7.0, in favor ofexplicitRepeatable(Class, Class)Create aRepeatableContainersinstance that searches for repeated annotations by taking into account the supplied repeatable and container annotation types.WARNING: The
RepeatableContainersinstance returned by this factory method does not respect Java's@Repeatablesupport. UsestandardRepeatables()for standard@Repeatablesupport, optionally combined withplus(Class, Class).WARNING: The arguments supplied to this method are in the reverse order of those supplied to
and(Class, Class).If the supplied container annotation type is not
null, it must declare avalueattribute returning an array of repeatable annotations. If the supplied container annotation type isnull, the container will be deduced by inspecting the@Repeatableannotation on therepeatableannotation type.- Parameters:
repeatable- the repeatable annotation typecontainer- the container annotation type ornull- Returns:
- a
RepeatableContainersinstance that does not support@Repeatable - Throws:
IllegalArgumentException- if the supplied container type isnulland the annotation type is not a repeatable annotationAnnotationConfigurationException- if the supplied container type is not a properly configured container for a repeatable annotation
-
none
Create aRepeatableContainersinstance that does not support any repeatable annotations.Note, however, that
plus(Class, Class)may still be invoked on theRepeatableContainersinstance returned from this method.See the class-level javadoc for examples and further details.
- Returns:
- a
RepeatableContainersinstance that does not support repeatable annotations
-
plus(Class, Class)