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

pack-priv final Class MergedAnnotationsCollection

extends Object
implements MergedAnnotations
Class Inheritance
All Implemented Interfaces
org.springframework.core.annotation.MergedAnnotations, java.lang.Iterable
Imports
java.lang.annotation.Annotation, java.util.Collection, .Iterator, .Spliterator, .Spliterators, java.util.function.Consumer, .Predicate, java.util.stream.Stream, .StreamSupport, org.springframework.lang.Nullable, org.springframework.util.Assert

MergedAnnotations implementation backed by a Collection of MergedAnnotation instances that represent direct annotations.
Author
Phillip Webb
Since
5.2
See Also
MergedAnnotations#of(Collection)

Nested and Inner Type Summary

Modifier and TypeClass and Description
private class

Field Summary

Modifier and TypeField and Description
private final MergedAnnotation<?>[]
private final AnnotationTypeMappings[]

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
private <A extends Annotation> MergedAnnotation<A>
find(Object requiredType, Predicate<? super MergedAnnotation<A>> predicate, MergedAnnotationSelector<A> selector)

public <A extends Annotation> MergedAnnotation<A>
get(Class<A>
the annotation type to get
annotationType
)

Implements org.springframework.core.annotation.MergedAnnotations.get.

Get the nearest matching annotation or meta-annotation of the specified type, or MergedAnnotation#missing() if none is present.
public <A extends Annotation> MergedAnnotation<A>
get(Class<A>
the annotation type to get
annotationType
,
Predicate<? super MergedAnnotation<A>>
a predicate that must match, or null if only type matching is required
predicate
)

Implements org.springframework.core.annotation.MergedAnnotations.get.

Get the nearest matching annotation or meta-annotation of the specified type, or MergedAnnotation#missing() if none is present.
public <A extends Annotation> MergedAnnotation<A>
get(Class<A>
the annotation type to get
annotationType
,
Predicate<? super MergedAnnotation<A>>
a predicate that must match, or null if only type matching is required
predicate
,
MergedAnnotationSelector<A>
a selector used to choose the most appropriate annotation within an aggregate, or null to select the nearest
selector
)

Implements org.springframework.core.annotation.MergedAnnotations.get.

Get a matching annotation or meta-annotation of the specified type, or MergedAnnotation#missing() if none is present.
public <A extends Annotation> MergedAnnotation<A>
get(String
the fully qualified class name of the annotation type to get
annotationType
)

Implements org.springframework.core.annotation.MergedAnnotations.get.

Get the nearest matching annotation or meta-annotation of the specified type, or MergedAnnotation#missing() if none is present.
public <A extends Annotation> MergedAnnotation<A>
get(String
the fully qualified class name of the annotation type to get
annotationType
,
Predicate<? super MergedAnnotation<A>>
a predicate that must match, or null if only type matching is required
predicate
)

Implements org.springframework.core.annotation.MergedAnnotations.get.

Get the nearest matching annotation or meta-annotation of the specified type, or MergedAnnotation#missing() if none is present.
public <A extends Annotation> MergedAnnotation<A>
get(String
the fully qualified class name of the annotation type to get
annotationType
,
Predicate<? super MergedAnnotation<A>>
a predicate that must match, or null if only type matching is required
predicate
,
MergedAnnotationSelector<A>
a selector used to choose the most appropriate annotation within an aggregate, or null to select the nearest
selector
)

Implements org.springframework.core.annotation.MergedAnnotations.get.

Get a matching annotation or meta-annotation of the specified type, or MergedAnnotation#missing() if none is present.
public <A extends Annotation> boolean
isDirectlyPresent(Class<A>
the annotation type to check
annotationType
)

Implements org.springframework.core.annotation.MergedAnnotations.isDirectlyPresent.

Determine if the specified annotation type is directly present.
public boolean
isDirectlyPresent(String
the fully qualified class name of the annotation type to check
annotationType
)

Implements org.springframework.core.annotation.MergedAnnotations.isDirectlyPresent.

Determine if the specified annotation type is directly present.
private static boolean
public <A extends Annotation> boolean
isPresent(Class<A>
the annotation type to check
annotationType
)

Implements org.springframework.core.annotation.MergedAnnotations.isPresent.

Determine if the specified annotation type is either directly present or meta-present.
public boolean
isPresent(String
the fully qualified class name of the annotation type to check
annotationType
)

Implements org.springframework.core.annotation.MergedAnnotations.isPresent.

Determine if the specified annotation type is either directly present or meta-present.
private boolean
isPresent(Object requiredType, boolean directOnly)

public Iterator<MergedAnnotation<Annotation>>
iterator()

Implements java.lang.Iterable.iterator.

Returns an iterator over elements of type T.
pack-priv static MergedAnnotations
of(Collection<MergedAnnotation<?>>
the annotations to include
annotations
)

Hides org.springframework.core.annotation.MergedAnnotations.of.

Create a new MergedAnnotations instance from the specified collection of directly present annotations.
public Spliterator<MergedAnnotation<Annotation>>
spliterator()

Overrides default java.lang.Iterable.spliterator.

Creates a Spliterator over the elements described by this Iterable.
private <A extends Annotation> Spliterator<MergedAnnotation<A>>
spliterator(Object annotationType)

public <A extends Annotation> Stream<MergedAnnotation<A>>
stream(Class<A>
the annotation type to match
annotationType
)

Implements org.springframework.core.annotation.MergedAnnotations.stream.

Stream all annotations and meta-annotations that match the specified type.
public <A extends Annotation> Stream<MergedAnnotation<A>>
stream(String
the fully qualified class name of the annotation type to match
annotationType
)

Implements org.springframework.core.annotation.MergedAnnotations.stream.

Stream all annotations and meta-annotations that match the specified type.
public Stream<MergedAnnotation<Annotation>>
stream()

Implements org.springframework.core.annotation.MergedAnnotations.stream.

Stream all annotations and meta-annotations contained in this collection.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

annotationsback to summary
private final MergedAnnotation<?>[] annotations
mappingsback to summary
private final AnnotationTypeMappings[] mappings

Constructor Detail

MergedAnnotationsCollectionback to summary
private MergedAnnotationsCollection(Collection<MergedAnnotation<?>> annotations)

Method Detail

findback to summary
private <A extends Annotation> MergedAnnotation<A> find(Object requiredType, Predicate<? super MergedAnnotation<A>> predicate, MergedAnnotationSelector<A> selector)
Annotations
@SuppressWarnings:unchecked
@Nullable
getback to summary
public <A extends Annotation> MergedAnnotation<A> get(Class<A> annotationType)

Implements org.springframework.core.annotation.MergedAnnotations.get.

Doc from org.springframework.core.annotation.MergedAnnotations.get.

Get the nearest matching annotation or meta-annotation of the specified type, or MergedAnnotation#missing() if none is present.

Parameters
annotationType:Class<A>

the annotation type to get

Returns:MergedAnnotation<A>

a MergedAnnotation instance

Annotations
@Override
getback to summary
public <A extends Annotation> MergedAnnotation<A> get(Class<A> annotationType, Predicate<? super MergedAnnotation<A>> predicate)

Implements org.springframework.core.annotation.MergedAnnotations.get.

Doc from org.springframework.core.annotation.MergedAnnotations.get.

Get the nearest matching annotation or meta-annotation of the specified type, or MergedAnnotation#missing() if none is present.

Parameters
annotationType:Class<A>

the annotation type to get

predicate:Predicate<? super MergedAnnotation<A>>

a predicate that must match, or null if only type matching is required

Returns:MergedAnnotation<A>

a MergedAnnotation instance

Annotations
@Override
getback to summary
public <A extends Annotation> MergedAnnotation<A> get(Class<A> annotationType, Predicate<? super MergedAnnotation<A>> predicate, MergedAnnotationSelector<A> selector)

Implements org.springframework.core.annotation.MergedAnnotations.get.

Doc from org.springframework.core.annotation.MergedAnnotations.get.

Get a matching annotation or meta-annotation of the specified type, or MergedAnnotation#missing() if none is present.

Parameters
annotationType:Class<A>

the annotation type to get

predicate:Predicate<? super MergedAnnotation<A>>

a predicate that must match, or null if only type matching is required

selector:MergedAnnotationSelector<A>

a selector used to choose the most appropriate annotation within an aggregate, or null to select the nearest

Returns:MergedAnnotation<A>

a MergedAnnotation instance

Annotations
@Override
getback to summary
public <A extends Annotation> MergedAnnotation<A> get(String annotationType)

Implements org.springframework.core.annotation.MergedAnnotations.get.

Doc from org.springframework.core.annotation.MergedAnnotations.get.

Get the nearest matching annotation or meta-annotation of the specified type, or MergedAnnotation#missing() if none is present.

Parameters
annotationType:String

the fully qualified class name of the annotation type to get

Returns:MergedAnnotation<A>

a MergedAnnotation instance

Annotations
@Override
getback to summary
public <A extends Annotation> MergedAnnotation<A> get(String annotationType, Predicate<? super MergedAnnotation<A>> predicate)

Implements org.springframework.core.annotation.MergedAnnotations.get.

Doc from org.springframework.core.annotation.MergedAnnotations.get.

Get the nearest matching annotation or meta-annotation of the specified type, or MergedAnnotation#missing() if none is present.

Parameters
annotationType:String

the fully qualified class name of the annotation type to get

predicate:Predicate<? super MergedAnnotation<A>>

a predicate that must match, or null if only type matching is required

Returns:MergedAnnotation<A>

a MergedAnnotation instance

Annotations
@Override
getback to summary
public <A extends Annotation> MergedAnnotation<A> get(String annotationType, Predicate<? super MergedAnnotation<A>> predicate, MergedAnnotationSelector<A> selector)

Implements org.springframework.core.annotation.MergedAnnotations.get.

Doc from org.springframework.core.annotation.MergedAnnotations.get.

Get a matching annotation or meta-annotation of the specified type, or MergedAnnotation#missing() if none is present.

Parameters
annotationType:String

the fully qualified class name of the annotation type to get

predicate:Predicate<? super MergedAnnotation<A>>

a predicate that must match, or null if only type matching is required

selector:MergedAnnotationSelector<A>

a selector used to choose the most appropriate annotation within an aggregate, or null to select the nearest

Returns:MergedAnnotation<A>

a MergedAnnotation instance

Annotations
@Override
isDirectlyPresentback to summary
public <A extends Annotation> boolean isDirectlyPresent(Class<A> annotationType)

Implements org.springframework.core.annotation.MergedAnnotations.isDirectlyPresent.

Doc from org.springframework.core.annotation.MergedAnnotations.isDirectlyPresent.

Determine if the specified annotation type is directly present.

Equivalent to calling get(annotationType).isDirectlyPresent().

Parameters
annotationType:Class<A>

the annotation type to check

Returns:boolean

true if the annotation is directly present

Annotations
@Override
isDirectlyPresentback to summary
public boolean isDirectlyPresent(String annotationType)

Implements org.springframework.core.annotation.MergedAnnotations.isDirectlyPresent.

Doc from org.springframework.core.annotation.MergedAnnotations.isDirectlyPresent.

Determine if the specified annotation type is directly present.

Equivalent to calling get(annotationType).isDirectlyPresent().

Parameters
annotationType:String

the fully qualified class name of the annotation type to check

Returns:boolean

true if the annotation is directly present

Annotations
@Override
isMappingForTypeback to summary
private static boolean isMappingForType(AnnotationTypeMapping mapping, Object requiredType)
isPresentback to summary
public <A extends Annotation> boolean isPresent(Class<A> annotationType)

Implements org.springframework.core.annotation.MergedAnnotations.isPresent.

Doc from org.springframework.core.annotation.MergedAnnotations.isPresent.

Determine if the specified annotation type is either directly present or meta-present.

Equivalent to calling get(annotationType).isPresent().

Parameters
annotationType:Class<A>

the annotation type to check

Returns:boolean

true if the annotation is present

Annotations
@Override
isPresentback to summary
public boolean isPresent(String annotationType)

Implements org.springframework.core.annotation.MergedAnnotations.isPresent.

Doc from org.springframework.core.annotation.MergedAnnotations.isPresent.

Determine if the specified annotation type is either directly present or meta-present.

Equivalent to calling get(annotationType).isPresent().

Parameters
annotationType:String

the fully qualified class name of the annotation type to check

Returns:boolean

true if the annotation is present

Annotations
@Override
isPresentback to summary
private boolean isPresent(Object requiredType, boolean directOnly)
iteratorback to summary
public Iterator<MergedAnnotation<Annotation>> iterator()

Implements java.lang.Iterable.iterator.

Doc from java.lang.Iterable.iterator.

Returns an iterator over elements of type T.

Returns:Iterator<MergedAnnotation<Annotation>>

an Iterator.

Annotations
@Override
ofback to summary
pack-priv static MergedAnnotations of(Collection<MergedAnnotation<?>> annotations)

Hides org.springframework.core.annotation.MergedAnnotations.of.

Doc from org.springframework.core.annotation.MergedAnnotations.of.

Create a new MergedAnnotations instance from the specified collection of directly present annotations. This method allows a MergedAnnotations instance to be created from annotations that are not necessarily loaded using reflection. The provided annotations must all be directly present and must have an aggregate index of 0.

The resulting MergedAnnotations instance will contain both the specified annotations and any meta-annotations that can be read using reflection.

Parameters
annotations:Collection<MergedAnnotation<?>>

the annotations to include

Returns:MergedAnnotations

a MergedAnnotations instance containing the annotations

spliteratorback to summary
public Spliterator<MergedAnnotation<Annotation>> spliterator()

Overrides default java.lang.Iterable.spliterator.

Doc from java.lang.Iterable.spliterator.

Creates a Spliterator over the elements described by this Iterable.

Returns:Spliterator<MergedAnnotation<Annotation>>

a Spliterator over the elements described by this Iterable.

Annotations
@Override
spliteratorback to summary
private <A extends Annotation> Spliterator<MergedAnnotation<A>> spliterator(Object annotationType)
streamback to summary
public <A extends Annotation> Stream<MergedAnnotation<A>> stream(Class<A> annotationType)

Implements org.springframework.core.annotation.MergedAnnotations.stream.

Doc from org.springframework.core.annotation.MergedAnnotations.stream.

Stream all annotations and meta-annotations that match the specified type.

The resulting stream follows the same ordering rules as stream().

Parameters
annotationType:Class<A>

the annotation type to match

Returns:Stream<MergedAnnotation<A>>

a stream of matching annotations

Annotations
@Override
streamback to summary
public <A extends Annotation> Stream<MergedAnnotation<A>> stream(String annotationType)

Implements org.springframework.core.annotation.MergedAnnotations.stream.

Doc from org.springframework.core.annotation.MergedAnnotations.stream.

Stream all annotations and meta-annotations that match the specified type.

The resulting stream follows the same ordering rules as stream().

Parameters
annotationType:String

the fully qualified class name of the annotation type to match

Returns:Stream<MergedAnnotation<A>>

a stream of matching annotations

Annotations
@Override
streamback to summary
public Stream<MergedAnnotation<Annotation>> stream()

Implements org.springframework.core.annotation.MergedAnnotations.stream.

Doc from org.springframework.core.annotation.MergedAnnotations.stream.

Stream all annotations and meta-annotations contained in this collection.

The resulting stream is ordered first by the aggregate index and then by the annotation distance (with the closest annotations first). This ordering means that, for most use-cases, the most suitable annotations appear earliest in the stream.

Returns:Stream<MergedAnnotation<Annotation>>

a stream of annotations

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

private Class MergedAnnotationsCollection.AnnotationsSpliterator<A extends java.lang.annotation.Annotation>

extends Object
implements Spliterator<MergedAnnotation<A extends Annotation>>
Class Inheritance
  • java.lang.Object
  • org.springframework.core.annotation.MergedAnnotationsCollection.AnnotationsSpliterator
All Implemented Interfaces
java.util.Spliterator

Field Summary

Modifier and TypeField and Description
private final int[]
private final Object

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public int
characteristics()

Implements java.util.Spliterator.characteristics.

Returns a set of characteristics of this Spliterator and its elements.
private MergedAnnotation<A>
createMergedAnnotationIfPossible(int annotationIndex, int mappingIndex)

public long
estimateSize()

Implements java.util.Spliterator.estimateSize.

Returns an estimate of the number of elements that would be encountered by a forEachRemaining traversal, or returns Long#MAX_VALUE if infinite, unknown, or too expensive to compute.
private AnnotationTypeMapping
getMapping(int annotationIndex, int mappingIndex)

private AnnotationTypeMapping
getNextSuitableMapping(int annotationIndex)

public boolean
tryAdvance(Consumer<? super MergedAnnotation<A>>
The action whose operation is performed at-most once
action
)

Implements java.util.Spliterator.tryAdvance.

If a remaining element exists: performs the given action on it, returning true; else returns false.
public Spliterator<MergedAnnotation<A>>
trySplit()

Implements java.util.Spliterator.trySplit.

If this spliterator can be partitioned, returns a Spliterator covering elements, that will, upon return from this method, not be covered by this Spliterator.
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

mappingCursorsback to summary
private final int[] mappingCursors
requiredTypeback to summary
private final Object requiredType
Annotations
@Nullable

Constructor Detail

AnnotationsSpliteratorback to summary
public AnnotationsSpliterator(Object requiredType)

Method Detail

characteristicsback to summary
public int characteristics()

Implements java.util.Spliterator.characteristics.

Doc from java.util.Spliterator.characteristics.

Returns a set of characteristics of this Spliterator and its elements. The result is represented as ORed values from ORDERED, DISTINCT, SORTED, SIZED, NONNULL, IMMUTABLE, CONCURRENT, SUBSIZED. Repeated calls to characteristics() on a given spliterator, prior to or in-between calls to trySplit, should always return the same result.

If a Spliterator reports an inconsistent set of characteristics (either those returned from a single invocation or across multiple invocations), no guarantees can be made about any computation using this Spliterator.

Returns:int

a representation of characteristics

Annotations
@Override
createMergedAnnotationIfPossibleback to summary
private MergedAnnotation<A> createMergedAnnotationIfPossible(int annotationIndex, int mappingIndex)
Annotations
@Nullable
@SuppressWarnings:unchecked
estimateSizeback to summary
public long estimateSize()

Implements java.util.Spliterator.estimateSize.

Doc from java.util.Spliterator.estimateSize.

Returns an estimate of the number of elements that would be encountered by a forEachRemaining traversal, or returns Long#MAX_VALUE if infinite, unknown, or too expensive to compute.

If this Spliterator is SIZED and has not yet been partially traversed or split, or this Spliterator is SUBSIZED and has not yet been partially traversed, this estimate must be an accurate count of elements that would be encountered by a complete traversal. Otherwise, this estimate may be arbitrarily inaccurate, but must decrease as specified across invocations of trySplit.

Returns:long

the estimated size, or Long.MAX_VALUE if infinite, unknown, or too expensive to compute.

Annotations
@Override
getMappingback to summary
private AnnotationTypeMapping getMapping(int annotationIndex, int mappingIndex)
Annotations
@Nullable
getNextSuitableMappingback to summary
private AnnotationTypeMapping getNextSuitableMapping(int annotationIndex)
Annotations
@Nullable
tryAdvanceback to summary
public boolean tryAdvance(Consumer<? super MergedAnnotation<A>> action)

Implements java.util.Spliterator.tryAdvance.

Doc from java.util.Spliterator.tryAdvance.

If a remaining element exists: performs the given action on it, returning true; else returns false. If this Spliterator is ORDERED the action is performed on the next element in encounter order. Exceptions thrown by the action are relayed to the caller.

Subsequent behavior of a spliterator is unspecified if the action throws an exception.

Parameters
action:Consumer<? super MergedAnnotation<A>>

The action whose operation is performed at-most once

Returns:boolean

false if no remaining elements existed upon entry to this method, else true.

Annotations
@Override
trySplitback to summary
public Spliterator<MergedAnnotation<A>> trySplit()

Implements java.util.Spliterator.trySplit.

Doc from java.util.Spliterator.trySplit.

If this spliterator can be partitioned, returns a Spliterator covering elements, that will, upon return from this method, not be covered by this Spliterator.

If this Spliterator is ORDERED, the returned Spliterator must cover a strict prefix of the elements.

Unless this Spliterator covers an infinite number of elements, repeated calls to trySplit() must eventually return null. Upon non-null return:

  • the value reported for estimateSize() before splitting, must, after splitting, be greater than or equal to estimateSize() for this and the returned Spliterator; and
  • if this Spliterator is SUBSIZED, then estimateSize() for this spliterator before splitting must be equal to the sum of estimateSize() for this and the returned Spliterator after splitting.

This method may return null for any reason, including emptiness, inability to split after traversal has commenced, data structure constraints, and efficiency considerations.

Returns:Spliterator<MergedAnnotation<A>>

a Spliterator covering some portion of the elements, or null if this spliterator cannot be split

Annotations
@Override
@Nullable