Interface AnnotationOverlay
- All Known Subinterfaces:
MutableAnnotationOverlay
- Since:
- 3.2.0
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic final classThe builder for an annotation overlay. -
Method Summary
Modifier and TypeMethodDescriptiondefault AnnotationInstanceannotation(Declaration declaration, Class<? extends Annotation> clazz) Returns the annotation instance of givenclazzdeclared on givendeclaration.annotation(Declaration declaration, DotName name) Returns the annotation instance with givennamedeclared 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 givennamedeclared on givendeclaration.static AnnotationOverlay.Builderbuilder(IndexView index, Collection<AnnotationTransformation> annotationTransformations) Returns a new builder for an annotation overlay for givenindexand a given collection oftransformations.default booleanhasAnnotation(Declaration declaration, Class<? extends Annotation> clazz) Returns whether an annotation instance of givenclazzis declared on givendeclaration.booleanhasAnnotation(Declaration declaration, DotName name) Returns whether an annotation instance with givennameis declared on givendeclaration.default booleanhasAnyAnnotation(Declaration declaration, Class<? extends Annotation>... classes) Returns whether any annotation instance of one of givenclassesis declared on givendeclaration.booleanhasAnyAnnotation(Declaration declaration, Set<DotName> names) Returns whether any annotation instance with one of givennamesis 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 givenindexand 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 benullannotationTransformations- 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 givennameis 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 benullname- name of the annotation type to look for, must not benull- Returns:
trueif the annotation is present,falseotherwise
-
hasAnnotation
Returns whether an annotation instance of givenclazzis 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 benullclazz- the annotation type to look for, must not benull- Returns:
trueif the annotation is present,falseotherwise- See Also:
-
hasAnyAnnotation
Returns whether any annotation instance with one of givennamesis 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 benullnames- names of the annotation types to look for, must not benull- Returns:
trueif any of the annotations is present,falseotherwise
-
hasAnyAnnotation
Returns whether any annotation instance of one of givenclassesis 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 benullclasses- annotation types to look for, must not benull- Returns:
trueif any of the annotations is present,falseotherwise
-
annotation
Returns the annotation instance with givennamedeclared 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 givennameis present, an unspecified instance is returned.- Parameters:
declaration- the declaration to inspect, must not benullname- name of the annotation type to look for, must not benull- Returns:
- the annotation instance, or
nullif not found
-
annotation
Returns the annotation instance of givenclazzdeclared 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 givenclazzis present, an unspecified instance is returned.- Parameters:
declaration- the declaration to inspect, must not benullclazz- the annotation type to look for, must not benull- Returns:
- the annotation instance, or
nullif not found - See Also:
-
annotationsWithRepeatable
Returns the annotation instances with givennamedeclared 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 benullname- 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 benullclazz- 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
-