Top Description Inners Fields Constructors Methods
org.springframework.core.annotation

public abstract Class RepeatableContainers

extends Object
Class Inheritance
Known Direct Subclasses
org.springframework.core.annotation.RepeatableContainers.StandardRepeatableContainers, org.springframework.core.annotation.RepeatableContainers.ExplicitRepeatableContainer, org.springframework.core.annotation.RepeatableContainers.NoRepeatableContainers
Imports
java.lang.annotation.Annotation, .Repeatable, java.lang.reflect.Method, java.util.Map, .Objects, org.springframework.lang.Nullable, org.springframework.util.Assert, .ConcurrentReferenceHashMap, .ObjectUtils

Strategy used to determine annotations that act as containers for other annotations. The standardRepeatables() method provides a default strategy that respects Java's @Repeatable support and should be suitable for most situations.

The of method can be used to register relationships for annotations that do not wish to use @Repeatable.

To completely disable repeatable support use none().

Authors
Phillip Webb, Sam Brannen
Since
5.2

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static class
private static class
private static class
RepeatableContainers.StandardRepeatableContainers

Standard RepeatableContainers implementation that searches using Java's @Repeatable annotation.

Field Summary

Modifier and TypeField and Description
pack-priv static final Map<Class<? extends Annotation>, Object>
private final RepeatableContainers

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public RepeatableContainers

Returns:

a new RepeatableContainers instance
and
(Class<? extends Annotation>
the container annotation type
container
,
Class<? extends Annotation>
the repeatable annotation type
repeatable
)

Add an additional explicit relationship between a container and repeatable annotation.

public boolean
equals(Object
the reference object with which to compare.
other
)

Overrides java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.
pack-priv Annotation[]
public int
hashCode()

Overrides java.lang.Object.hashCode.

Returns a hash code value for the object.
public static RepeatableContainers

Returns:

a RepeatableContainers instance
none
()

Create a RepeatableContainers instance that does not support any repeatable annotations.

public static RepeatableContainers

Returns:

a RepeatableContainers instance
of
(Class<? extends Annotation>
the repeatable annotation type
repeatable
,
Class<? extends Annotation>
the container annotation type or null. If specified, this annotation must declare a value attribute returning an array of repeatable annotations. If not specified, the container will be deduced by inspecting the @Repeatable annotation on repeatable.
container
)

Create a RepeatableContainers instance that uses predefined repeatable and container types.

public static RepeatableContainers

Returns:

a RepeatableContainers instance
standardRepeatables
()

Create a RepeatableContainers instance that searches using Java's @Repeatable annotation.

Inherited from java.lang.Object:
clonefinalizegetClassnotifynotifyAlltoStringwaitwaitwait

Field Detail

cacheback to summary
pack-priv static final Map<Class<? extends Annotation>, Object> cache
parentback to summary
private final RepeatableContainers parent
Annotations
@Nullable

Constructor Detail

RepeatableContainersback to summary
private RepeatableContainers(RepeatableContainers parent)

Method Detail

andback to summary
public RepeatableContainers and(Class<? extends Annotation> container, Class<? extends Annotation> repeatable)

Add an additional explicit relationship between a container and repeatable annotation.

Warning

the arguments supplied to this method are in the reverse order of those supplied to of(Class, Class).

Parameters
container:Class<? extends Annotation>

the container annotation type

repeatable:Class<? extends Annotation>

the repeatable annotation type

Returns:RepeatableContainers

a new RepeatableContainers instance

equalsback to summary
public boolean equals(Object other)

Overrides java.lang.Object.equals.

Doc from java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.

The equals method implements an equivalence relation on non-null object references:

  • It is reflexive: for any non-null reference value x, x.equals(x) should return true.
  • It is symmetric: for any non-null reference values x and y, x.equals(y) should return true if and only if y.equals(x) returns true.
  • It is transitive: for any non-null reference values x, y, and z, if x.equals(y) returns true and y.equals(z) returns true, then x.equals(z) should return true.
  • It is consistent: for any non-null reference values x and y, multiple invocations of x.equals(y) consistently return true or consistently return false, provided no information used in equals comparisons on the objects is modified.
  • For any non-null reference value x, x.equals(null) should return false.

An equivalence relation partitions the elements it operates on into equivalence classes; all the members of an equivalence class are equal to each other. Members of an equivalence class are substitutable for each other, at least for some purposes.

Parameters
other:Object

the reference object with which to compare.

Returns:boolean

true if this object is the same as the obj argument; false otherwise.

Annotations
@Override
findRepeatedAnnotationsback to summary
pack-priv Annotation[] findRepeatedAnnotations(Annotation annotation)
Annotations
@Nullable
hashCodeback to summary
public int hashCode()

Overrides java.lang.Object.hashCode.

Doc from java.lang.Object.hashCode.

Returns a hash code value for the object. This method is supported for the benefit of hash tables such as those provided by java.util.HashMap.

The general contract of hashCode is:

  • Whenever it is invoked on the same object more than once during an execution of a Java application, the hashCode method must consistently return the same integer, provided no information used in equals comparisons on the object is modified. This integer need not remain consistent from one execution of an application to another execution of the same application.
  • If two objects are equal according to the equals method, then calling the hashCode method on each of the two objects must produce the same integer result.
  • It is not required that if two objects are unequal according to the equals method, then calling the hashCode method on each of the two objects must produce distinct integer results. However, the programmer should be aware that producing distinct integer results for unequal objects may improve the performance of hash tables.
Returns:int

a hash code value for this object.

Annotations
@Override
noneback to summary
public static RepeatableContainers none()

Create a RepeatableContainers instance that does not support any repeatable annotations.

Returns:RepeatableContainers

a RepeatableContainers instance

ofback to summary
public static RepeatableContainers of(Class<? extends Annotation> repeatable, Class<? extends Annotation> container)

Create a RepeatableContainers instance that uses predefined repeatable and container types.

Warning

the arguments supplied to this method are in the reverse order of those supplied to and(Class, Class).

Parameters
repeatable:Class<? extends Annotation>

the repeatable annotation type

container:Class<? extends Annotation>

the container annotation type or null. If specified, this annotation must declare a value attribute returning an array of repeatable annotations. If not specified, the container will be deduced by inspecting the @Repeatable annotation on repeatable.

Returns:RepeatableContainers

a RepeatableContainers instance

Exceptions
IllegalArgumentException:
if the supplied container type is null and the annotation type is not a repeatable annotation
AnnotationConfigurationException:
if the supplied container type is not a properly configured container for a repeatable annotation
standardRepeatablesback to summary
public static RepeatableContainers standardRepeatables()

Create a RepeatableContainers instance that searches using Java's @Repeatable annotation.

Returns:RepeatableContainers

a RepeatableContainers instance

org.springframework.core.annotation back to summary

private Class RepeatableContainers.ExplicitRepeatableContainer

extends RepeatableContainers
Class Inheritance

A single explicit mapping.

Field Summary

Modifier and TypeField and Description
private final Class<? extends Annotation>
private final Class<? extends Annotation>
private final Method
Inherited from org.springframework.core.annotation.RepeatableContainers:
cache

Constructor Summary

AccessConstructor and Description
pack-priv
ExplicitRepeatableContainer(RepeatableContainers parent, Class<? extends Annotation> repeatable, Class<? extends Annotation> container)

Method Summary

Modifier and TypeMethod and Description
private Class<? extends Annotation>
deduceContainer(Class<? extends Annotation> repeatable)

public boolean
equals(Object
the reference object with which to compare.
other
)

Overrides org.springframework.core.annotation.RepeatableContainers.equals.

Indicates whether some other object is "equal to" this one.
pack-priv Annotation[]
public int
hashCode()

Overrides org.springframework.core.annotation.RepeatableContainers.hashCode.

Returns a hash code value for the object.
Inherited from org.springframework.core.annotation.RepeatableContainers:
andnoneofstandardRepeatables

Field Detail

containerback to summary
private final Class<? extends Annotation> container
repeatableback to summary
private final Class<? extends Annotation> repeatable
valueMethodback to summary
private final Method valueMethod

Constructor Detail

ExplicitRepeatableContainerback to summary
pack-priv ExplicitRepeatableContainer(RepeatableContainers parent, Class<? extends Annotation> repeatable, Class<? extends Annotation> container)

Method Detail

deduceContainerback to summary
private Class<? extends Annotation> deduceContainer(Class<? extends Annotation> repeatable)
equalsback to summary
public boolean equals(Object other)

Overrides org.springframework.core.annotation.RepeatableContainers.equals.

Doc from java.lang.Object.equals.

Indicates whether some other object is "equal to" this one.

The equals method implements an equivalence relation on non-null object references:

  • It is reflexive: for any non-null reference value x, x.equals(x) should return true.
  • It is symmetric: for any non-null reference values x and y, x.equals(y) should return true if and only if y.equals(x) returns true.
  • It is transitive: for any non-null reference values x, y, and z, if x.equals(y) returns true and y.equals(z) returns true, then x.equals(z) should return true.
  • It is consistent: for any non-null reference values x and y, multiple invocations of x.equals(y) consistently return true or consistently return false, provided no information used in equals comparisons on the objects is modified.
  • For any non-null reference value x, x.equals(null) should return false.

An equivalence relation partitions the elements it operates on into equivalence classes; all the members of an equivalence class are equal to each other. Members of an equivalence class are substitutable for each other, at least for some purposes.

Parameters
other:Object

the reference object with which to compare.

Returns:boolean

true if this object is the same as the obj argument; false otherwise.

Annotations
@Override
findRepeatedAnnotationsback to summary
pack-priv Annotation[] findRepeatedAnnotations(Annotation annotation)

Overrides org.springframework.core.annotation.RepeatableContainers.findRepeatedAnnotations.

Annotations
@Override
@Nullable
hashCodeback to summary
public int hashCode()

Overrides org.springframework.core.annotation.RepeatableContainers.hashCode.

Doc from java.lang.Object.hashCode.

Returns a hash code value for the object. This method is supported for the benefit of hash tables such as those provided by java.util.HashMap.

The general contract of hashCode is:

  • Whenever it is invoked on the same object more than once during an execution of a Java application, the hashCode method must consistently return the same integer, provided no information used in equals comparisons on the object is modified. This integer need not remain consistent from one execution of an application to another execution of the same application.
  • If two objects are equal according to the equals method, then calling the hashCode method on each of the two objects must produce the same integer result.
  • It is not required that if two objects are unequal according to the equals method, then calling the hashCode method on each of the two objects must produce distinct integer results. However, the programmer should be aware that producing distinct integer results for unequal objects may improve the performance of hash tables.
Returns:int

a hash code value for this object.

Annotations
@Override
org.springframework.core.annotation back to summary

private Class RepeatableContainers.NoRepeatableContainers

extends RepeatableContainers
Class Inheritance

No repeatable containers.

Field Summary

Modifier and TypeField and Description
private static final RepeatableContainers.NoRepeatableContainers
Inherited from org.springframework.core.annotation.RepeatableContainers:
cache

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Inherited from org.springframework.core.annotation.RepeatableContainers:
andequalsfindRepeatedAnnotationshashCodenoneofstandardRepeatables

Field Detail

INSTANCEback to summary
private static final RepeatableContainers.NoRepeatableContainers INSTANCE

Constructor Detail

NoRepeatableContainersback to summary
pack-priv NoRepeatableContainers()
org.springframework.core.annotation back to summary

private Class RepeatableContainers.StandardRepeatableContainers

extends RepeatableContainers
Class Inheritance

Standard RepeatableContainers implementation that searches using Java's @Repeatable annotation.

Field Summary

Modifier and TypeField and Description
private static final RepeatableContainers.StandardRepeatableContainers
private static final Object
Inherited from org.springframework.core.annotation.RepeatableContainers:
cache

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
private static Object
pack-priv Annotation[]
private static Method
getRepeatedAnnotationsMethod(Class<? extends Annotation> annotationType)

Inherited from org.springframework.core.annotation.RepeatableContainers:
andequalshashCodenoneofstandardRepeatables

Field Detail

INSTANCEback to summary
private static final RepeatableContainers.StandardRepeatableContainers INSTANCE
NONEback to summary
private static final Object NONE

Constructor Detail

StandardRepeatableContainersback to summary
pack-priv StandardRepeatableContainers()

Method Detail

computeRepeatedAnnotationsMethodback to summary
private static Object computeRepeatedAnnotationsMethod(Class<? extends Annotation> annotationType)
findRepeatedAnnotationsback to summary
pack-priv Annotation[] findRepeatedAnnotations(Annotation annotation)

Overrides org.springframework.core.annotation.RepeatableContainers.findRepeatedAnnotations.

Annotations
@Override
@Nullable
getRepeatedAnnotationsMethodback to summary
private static Method getRepeatedAnnotationsMethod(Class<? extends Annotation> annotationType)
Annotations
@Nullable