final class TypeMappedAnnotations extends java.lang.Object implements MergedAnnotations
MergedAnnotations
implementation that searches for and adapts
annotations and meta-annotations using AnnotationTypeMappings
.Modifier and Type | Class and Description |
---|---|
private static class |
TypeMappedAnnotations.Aggregate |
private class |
TypeMappedAnnotations.AggregatesCollector
AnnotationsProcessor that collects TypeMappedAnnotations.Aggregate instances. |
private class |
TypeMappedAnnotations.AggregatesSpliterator<A extends java.lang.annotation.Annotation>
Spliterator used to consume merged annotations from the
aggregates in depth fist order. |
private static class |
TypeMappedAnnotations.IsPresent
AnnotationsProcessor used to detect if an annotation is directly
present or meta-present. |
private class |
TypeMappedAnnotations.MergedAnnotationFinder<A extends java.lang.annotation.Annotation>
AnnotationsProcessor that finds a single MergedAnnotation . |
MergedAnnotations.SearchStrategy
Modifier and Type | Field and Description |
---|---|
private java.util.List<TypeMappedAnnotations.Aggregate> |
aggregates |
private AnnotationFilter |
annotationFilter |
private java.lang.annotation.Annotation[] |
annotations |
private java.lang.reflect.AnnotatedElement |
element |
private static AnnotationFilter |
FILTER_ALL |
private static MergedAnnotations |
NONE |
private RepeatableContainers |
repeatableContainers |
private MergedAnnotations.SearchStrategy |
searchStrategy |
private java.lang.Object |
source |
Modifier | Constructor and Description |
---|---|
private |
TypeMappedAnnotations(java.lang.reflect.AnnotatedElement element,
MergedAnnotations.SearchStrategy searchStrategy,
RepeatableContainers repeatableContainers,
AnnotationFilter annotationFilter) |
private |
TypeMappedAnnotations(java.lang.Object source,
java.lang.annotation.Annotation[] annotations,
RepeatableContainers repeatableContainers,
AnnotationFilter annotationFilter) |
Modifier and Type | Method and Description |
---|---|
(package private) static MergedAnnotations |
from(java.lang.reflect.AnnotatedElement element,
MergedAnnotations.SearchStrategy searchStrategy,
RepeatableContainers repeatableContainers,
AnnotationFilter annotationFilter)
Create a new
MergedAnnotations instance containing all
annotations and meta-annotations from the specified element and,
depending on the MergedAnnotations.SearchStrategy , related inherited elements. |
(package private) static MergedAnnotations |
from(java.lang.Object source,
java.lang.annotation.Annotation[] annotations,
RepeatableContainers repeatableContainers,
AnnotationFilter annotationFilter)
Create a new
MergedAnnotations instance from the specified
annotations. |
<A extends java.lang.annotation.Annotation> |
get(java.lang.Class<A> annotationType)
Return the nearest matching
annotation or meta-annotation of the specified type, or
MergedAnnotation.missing() if none is present. |
<A extends java.lang.annotation.Annotation> |
get(java.lang.Class<A> annotationType,
java.util.function.Predicate<? super MergedAnnotation<A>> predicate)
Return the nearest matching
annotation or meta-annotation of the specified type, or
MergedAnnotation.missing() if none is present. |
<A extends java.lang.annotation.Annotation> |
get(java.lang.Class<A> annotationType,
java.util.function.Predicate<? super MergedAnnotation<A>> predicate,
MergedAnnotationSelector<A> selector)
Return a matching annotation or meta-annotation of the specified type, or
MergedAnnotation.missing() if none is present. |
<A extends java.lang.annotation.Annotation> |
get(java.lang.String annotationType)
Return the nearest matching
annotation or meta-annotation of the specified type, or
MergedAnnotation.missing() if none is present. |
<A extends java.lang.annotation.Annotation> |
get(java.lang.String annotationType,
java.util.function.Predicate<? super MergedAnnotation<A>> predicate)
Return the nearest matching
annotation or meta-annotation of the specified type, or
MergedAnnotation.missing() if none is present. |
<A extends java.lang.annotation.Annotation> |
get(java.lang.String annotationType,
java.util.function.Predicate<? super MergedAnnotation<A>> predicate,
MergedAnnotationSelector<A> selector)
Return a matching annotation or meta-annotation of the specified type, or
MergedAnnotation.missing() if none is present. |
private java.util.List<TypeMappedAnnotations.Aggregate> |
getAggregates() |
<A extends java.lang.annotation.Annotation> |
isDirectlyPresent(java.lang.Class<A> annotationType)
Determine if the specified annotation is directly present.
|
boolean |
isDirectlyPresent(java.lang.String annotationType)
Determine if the specified annotation is either directly present or
meta-present.
|
private static boolean |
isMappingForType(AnnotationTypeMapping mapping,
AnnotationFilter annotationFilter,
java.lang.Object requiredType) |
<A extends java.lang.annotation.Annotation> |
isPresent(java.lang.Class<A> annotationType)
Determine if the specified annotation is either directly present or
meta-present.
|
boolean |
isPresent(java.lang.String annotationType)
Determine if the specified annotation is directly present.
|
java.util.Iterator<MergedAnnotation<java.lang.annotation.Annotation>> |
iterator() |
private <C,R> R |
scan(C criteria,
AnnotationsProcessor<C,R> processor) |
java.util.Spliterator<MergedAnnotation<java.lang.annotation.Annotation>> |
spliterator() |
private <A extends java.lang.annotation.Annotation> |
spliterator(java.lang.Object annotationType) |
java.util.stream.Stream<MergedAnnotation<java.lang.annotation.Annotation>> |
stream()
Stream all annotations and meta-annotations contained in this collection.
|
<A extends java.lang.annotation.Annotation> |
stream(java.lang.Class<A> annotationType)
Stream all annotations and meta-annotations that match the specified
type.
|
<A extends java.lang.annotation.Annotation> |
stream(java.lang.String annotationType)
Stream all annotations and meta-annotations that match the specified
type.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
from, from, from, from
private static final AnnotationFilter FILTER_ALL
private static final MergedAnnotations NONE
@Nullable private final java.lang.Object source
@Nullable private final java.lang.reflect.AnnotatedElement element
@Nullable private final MergedAnnotations.SearchStrategy searchStrategy
@Nullable private final java.lang.annotation.Annotation[] annotations
private final RepeatableContainers repeatableContainers
private final AnnotationFilter annotationFilter
@Nullable private volatile java.util.List<TypeMappedAnnotations.Aggregate> aggregates
private TypeMappedAnnotations(java.lang.reflect.AnnotatedElement element, MergedAnnotations.SearchStrategy searchStrategy, RepeatableContainers repeatableContainers, AnnotationFilter annotationFilter)
private TypeMappedAnnotations(@Nullable java.lang.Object source, java.lang.annotation.Annotation[] annotations, RepeatableContainers repeatableContainers, AnnotationFilter annotationFilter)
public <A extends java.lang.annotation.Annotation> boolean isPresent(java.lang.Class<A> annotationType)
MergedAnnotations
Equivalent to calling get(annotationType).isPresent()
.
isPresent
in interface MergedAnnotations
annotationType
- the annotation type to checktrue
if the annotation is presentpublic boolean isPresent(java.lang.String annotationType)
MergedAnnotations
Equivalent to calling get(annotationType).isDirectlyPresent()
.
isPresent
in interface MergedAnnotations
annotationType
- the fully qualified class name of the annotation type
to checktrue
if the annotation is presentpublic <A extends java.lang.annotation.Annotation> boolean isDirectlyPresent(java.lang.Class<A> annotationType)
MergedAnnotations
Equivalent to calling get(annotationType).isDirectlyPresent()
.
isDirectlyPresent
in interface MergedAnnotations
annotationType
- the annotation type to checktrue
if the annotation is presentpublic boolean isDirectlyPresent(java.lang.String annotationType)
MergedAnnotations
Equivalent to calling get(annotationType).isPresent()
.
isDirectlyPresent
in interface MergedAnnotations
annotationType
- the fully qualified class name of the annotation type
to checktrue
if the annotation is presentpublic <A extends java.lang.annotation.Annotation> MergedAnnotation<A> get(java.lang.Class<A> annotationType)
MergedAnnotations
MergedAnnotation.missing()
if none is present.get
in interface MergedAnnotations
annotationType
- the annotation type to getMergedAnnotation
instancepublic <A extends java.lang.annotation.Annotation> MergedAnnotation<A> get(java.lang.Class<A> annotationType, @Nullable java.util.function.Predicate<? super MergedAnnotation<A>> predicate)
MergedAnnotations
MergedAnnotation.missing()
if none is present.get
in interface MergedAnnotations
annotationType
- the annotation type to getpredicate
- a predicate that must match, or null
if only
type matching is requiredMergedAnnotation
instanceMergedAnnotationPredicates
public <A extends java.lang.annotation.Annotation> MergedAnnotation<A> get(java.lang.Class<A> annotationType, @Nullable java.util.function.Predicate<? super MergedAnnotation<A>> predicate, @Nullable MergedAnnotationSelector<A> selector)
MergedAnnotations
MergedAnnotation.missing()
if none is present.get
in interface MergedAnnotations
annotationType
- the annotation type to getpredicate
- a predicate that must match, or null
if only
type matching is requiredselector
- a selector used to choose the most appropriate annotation
within an aggregate, or null
to select the
nearestMergedAnnotation
instanceMergedAnnotationPredicates
,
MergedAnnotationSelectors
public <A extends java.lang.annotation.Annotation> MergedAnnotation<A> get(java.lang.String annotationType)
MergedAnnotations
MergedAnnotation.missing()
if none is present.get
in interface MergedAnnotations
annotationType
- the fully qualified class name of the annotation type
to getMergedAnnotation
instancepublic <A extends java.lang.annotation.Annotation> MergedAnnotation<A> get(java.lang.String annotationType, @Nullable java.util.function.Predicate<? super MergedAnnotation<A>> predicate)
MergedAnnotations
MergedAnnotation.missing()
if none is present.get
in interface MergedAnnotations
annotationType
- the fully qualified class name of the annotation type
to getpredicate
- a predicate that must match, or null
if only
type matching is requiredMergedAnnotation
instanceMergedAnnotationPredicates
public <A extends java.lang.annotation.Annotation> MergedAnnotation<A> get(java.lang.String annotationType, @Nullable java.util.function.Predicate<? super MergedAnnotation<A>> predicate, @Nullable MergedAnnotationSelector<A> selector)
MergedAnnotations
MergedAnnotation.missing()
if none is present.get
in interface MergedAnnotations
annotationType
- the fully qualified class name of the annotation type
to getpredicate
- a predicate that must match, or null
if only
type matching is requiredselector
- a selector used to choose the most appropriate annotation
within an aggregate, or null
to select the
nearestMergedAnnotation
instanceMergedAnnotationPredicates
,
MergedAnnotationSelectors
public <A extends java.lang.annotation.Annotation> java.util.stream.Stream<MergedAnnotation<A>> stream(java.lang.Class<A> annotationType)
MergedAnnotations
MergedAnnotations.stream()
.stream
in interface MergedAnnotations
annotationType
- the annotation type to matchpublic <A extends java.lang.annotation.Annotation> java.util.stream.Stream<MergedAnnotation<A>> stream(java.lang.String annotationType)
MergedAnnotations
MergedAnnotations.stream()
.stream
in interface MergedAnnotations
annotationType
- the fully qualified class name of the annotation type
to matchpublic java.util.stream.Stream<MergedAnnotation<java.lang.annotation.Annotation>> stream()
MergedAnnotations
stream
in interface MergedAnnotations
public java.util.Iterator<MergedAnnotation<java.lang.annotation.Annotation>> iterator()
iterator
in interface java.lang.Iterable<MergedAnnotation<java.lang.annotation.Annotation>>
public java.util.Spliterator<MergedAnnotation<java.lang.annotation.Annotation>> spliterator()
spliterator
in interface java.lang.Iterable<MergedAnnotation<java.lang.annotation.Annotation>>
private <A extends java.lang.annotation.Annotation> java.util.Spliterator<MergedAnnotation<A>> spliterator(@Nullable java.lang.Object annotationType)
private java.util.List<TypeMappedAnnotations.Aggregate> getAggregates()
@Nullable private <C,R> R scan(C criteria, AnnotationsProcessor<C,R> processor)
static MergedAnnotations from(java.lang.reflect.AnnotatedElement element, MergedAnnotations.SearchStrategy searchStrategy, RepeatableContainers repeatableContainers, AnnotationFilter annotationFilter)
MergedAnnotations
MergedAnnotations
instance containing all
annotations and meta-annotations from the specified element and,
depending on the MergedAnnotations.SearchStrategy
, related inherited elements.from
in interface MergedAnnotations
element
- the source elementsearchStrategy
- the search strategy to userepeatableContainers
- the repeatable containers that may be used by
the element annotations or the meta-annotationsannotationFilter
- an annotation filter used to restrict the
annotations consideredMergedAnnotations
instance containing the merged
element annotationsstatic MergedAnnotations from(@Nullable java.lang.Object source, java.lang.annotation.Annotation[] annotations, RepeatableContainers repeatableContainers, AnnotationFilter annotationFilter)
MergedAnnotations
MergedAnnotations
instance from the specified
annotations.from
in interface MergedAnnotations
source
- the source for the annotations. This source is used only
for information and logging. It does not need to actually
contain the specified annotations, and it will not be searched.annotations
- the annotations to includerepeatableContainers
- the repeatable containers that may be used by
meta-annotationsannotationFilter
- an annotation filter used to restrict the
annotations consideredMergedAnnotations
instance containing the annotationsprivate static boolean isMappingForType(AnnotationTypeMapping mapping, AnnotationFilter annotationFilter, @Nullable java.lang.Object requiredType)