Interface AnnotationOverlay
- All Known Subinterfaces:
MutableAnnotationOverlay
- All Known Implementing Classes:
AnnotationOverlayImpl
,MutableAnnotationOverlayImpl
- Since:
- 3.2.0
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic final class
The builder for an annotation overlay. -
Method Summary
Modifier and TypeMethodDescriptiondefault AnnotationInstance
annotation
(Declaration declaration, Class<? extends Annotation> clazz) Returns the annotation instance of givenclazz
declared on givendeclaration
.annotation
(Declaration declaration, DotName name) Returns the annotation instance with givenname
declared on givendeclaration
.annotations
(Declaration declaration) Returns the annotation instances declared on givendeclaration
.default Collection
<AnnotationInstance> annotationsWithRepeatable
(Declaration declaration, Class<? extends Annotation> clazz) Returns the annotation instances of given type (clazz
) declared on givendeclaration
.annotationsWithRepeatable
(Declaration declaration, DotName name) Returns the annotation instances with givenname
declared on givendeclaration
.static AnnotationOverlay.Builder
builder
(IndexView index, Collection<AnnotationTransformation> annotationTransformations) Returns a new builder for an annotation overlay for givenindex
and a given collection oftransformations
.default boolean
hasAnnotation
(Declaration declaration, Class<? extends Annotation> clazz) Returns whether an annotation instance of givenclazz
is declared on givendeclaration
.boolean
hasAnnotation
(Declaration declaration, DotName name) Returns whether an annotation instance with givenname
is declared on givendeclaration
.default boolean
hasAnyAnnotation
(Declaration declaration, Class<? extends Annotation>... classes) Returns whether any annotation instance of one of givenclasses
is declared on givendeclaration
.boolean
hasAnyAnnotation
(Declaration declaration, Set<DotName> names) Returns whether any annotation instance with one of givennames
is declared on givendeclaration
.index()
Returns the index whose annotation information is being overlaid.
-
Method Details
-
builder
static AnnotationOverlay.Builder builder(IndexView index, Collection<AnnotationTransformation> annotationTransformations) Returns a new builder for an annotation overlay for givenindex
and a given collection oftransformations
.Thread safety
The object returned by the builder is immutable and can be shared between threads without safe publication.
- Parameters:
index
- the Jandex index, must not benull
annotationTransformations
- the collection of annotation transformations- Returns:
- the annotation overlay builder, never
null
-
index
IndexView index()Returns the index whose annotation information is being overlaid.- Returns:
- the index underlying this annotation overlay, never
null
-
hasAnnotation
Returns whether an annotation instance with givenname
is declared on givendeclaration
.Like
AnnotationTarget.hasDeclaredAnnotation(DotName)
, and unlikeAnnotationTarget.hasAnnotation(DotName)
, this method ignores annotations declared on nested annotation targets. This doesn't hold in case of methods in the compatible mode, where method parameters are considered part of methods.- Parameters:
declaration
- the declaration to inspect, must not benull
name
- name of the annotation type to look for, must not benull
- Returns:
true
if the annotation is present,false
otherwise
-
hasAnnotation
Returns whether an annotation instance of givenclazz
is declared on givendeclaration
.Like
AnnotationTarget.hasDeclaredAnnotation(Class)
, and unlikeAnnotationTarget.hasAnnotation(Class)
, this method ignores annotations declared on nested annotation targets. This doesn't hold in case of methods in the compatible mode, where method parameters are considered part of methods.- Parameters:
declaration
- the declaration to inspect, must not benull
clazz
- the annotation type to look for, must not benull
- Returns:
true
if the annotation is present,false
otherwise- See Also:
-
hasAnyAnnotation
Returns whether any annotation instance with one of givennames
is declared on givendeclaration
.This method ignores annotations declared on nested annotation targets. This doesn't hold in case of methods in the compatible mode, where method parameters are considered part of methods.
- Parameters:
declaration
- the declaration to inspect, must not benull
names
- names of the annotation types to look for, must not benull
- Returns:
true
if any of the annotations is present,false
otherwise
-
hasAnyAnnotation
Returns whether any annotation instance of one of givenclasses
is declared on givendeclaration
.This method ignores annotations declared on nested annotation targets. This doesn't hold in case of methods in the compatible mode, where method parameters are considered part of methods.
- Parameters:
declaration
- the declaration to inspect, must not benull
classes
- annotation types to look for, must not benull
- Returns:
true
if any of the annotations is present,false
otherwise
-
annotation
Returns the annotation instance with givenname
declared on givendeclaration
.Like
AnnotationTarget.declaredAnnotation(DotName)
, and unlikeAnnotationTarget.annotation(DotName)
, this method doesn't return annotations declared on nested annotation targets. This doesn't hold in case of methods in the compatible mode, where method parameters are considered part of methods. In such case, if more than one annotation of givenname
is present, an unspecified instance is returned.- Parameters:
declaration
- the declaration to inspect, must not benull
name
- name of the annotation type to look for, must not benull
- Returns:
- the annotation instance, or
null
if not found
-
annotation
Returns the annotation instance of givenclazz
declared on givendeclaration
.Like
AnnotationTarget.declaredAnnotation(Class)
, and unlikeAnnotationTarget.annotation(Class)
, this method doesn't return annotations declared on nested annotation targets. This doesn't hold in case of methods in the compatible mode, where method parameters are considered part of methods. In such case, if more than one annotation of givenclazz
is present, an unspecified instance is returned.- Parameters:
declaration
- the declaration to inspect, must not benull
clazz
- the annotation type to look for, must not benull
- Returns:
- the annotation instance, or
null
if not found - See Also:
-
annotationsWithRepeatable
Returns the annotation instances with givenname
declared on givendeclaration
. If the specified annotation is repeatable, the result also contains all values from the container annotation instance.The annotation class must be present in the index underlying this annotation overlay.
Like
AnnotationTarget.declaredAnnotationsWithRepeatable(DotName, IndexView)
, and unlikeAnnotationTarget.annotationsWithRepeatable(DotName, IndexView)
, this method doesn't return annotations declared on nested annotation targets. This doesn't hold in case of methods in the compatible mode, where method parameters are considered part of methods.- Parameters:
declaration
- the declaration to inspect, must not benull
name
- name of the annotation type, must not benull
- Returns:
- immutable collection of annotation instances, never
null
-
annotationsWithRepeatable
default Collection<AnnotationInstance> annotationsWithRepeatable(Declaration declaration, Class<? extends Annotation> clazz) Returns the annotation instances of given type (clazz
) declared on givendeclaration
. If the specified annotation is repeatable, the result also contains all values from the container annotation instance.The annotation class must be present in the index underlying this annotation overlay.
Like
AnnotationTarget.declaredAnnotationsWithRepeatable(Class, IndexView)
, and unlikeAnnotationTarget.annotationsWithRepeatable(Class, IndexView)
, this method doesn't return annotations declared on nested annotation targets. This doesn't hold in case of methods in the compatible mode, where method parameters are considered part of methods.- Parameters:
declaration
- the declaration to inspect, must not benull
clazz
- the annotation type, must not benull
- Returns:
- immutable collection of annotation instances, never
null
- See Also:
-
annotations
Returns the annotation instances declared on givendeclaration
.Like
AnnotationTarget.declaredAnnotations()
, and unlikeAnnotationTarget.annotations()
, this method doesn't return annotations declared on nested annotation targets. This doesn't hold in case of methods in the compatible mode, where method parameters are considered part of methods.- Parameters:
declaration
- the declaration to inspect, must not benull
- Returns:
- immutable collection of annotation instances, never
null
-