public interface AnnotationTarget
ClassInfo,
FieldInfo,
MethodInfo,
MethodParameterInfo| Modifier and Type | Interface and Description |
|---|---|
static class |
AnnotationTarget.Kind
Specifies the kind of object a target represents.
|
| Modifier and Type | Method and Description |
|---|---|
default AnnotationInstance |
annotation(Class<? extends Annotation> clazz)
Returns the annotation instance of given type declared on this annotation target or any of its nested
annotation targets.
|
AnnotationInstance |
annotation(DotName name)
Returns the annotation instance with given name declared on this annotation target or any of its nested
annotation targets.
|
default AnnotationInstance |
annotation(String name)
Returns the annotation instance with given name declared on this annotation target or any of its nested
annotation targets.
|
Collection<AnnotationInstance> |
annotations()
Returns the annotation instances declared on this annotation target and nested annotation targets.
|
default Collection<AnnotationInstance> |
annotations(Class<? extends Annotation> clazz)
Returns the annotation instances of given type declared on this annotation target and nested annotation targets.
|
Collection<AnnotationInstance> |
annotations(DotName name)
Returns the annotation instances with given name declared on this annotation target and nested annotation targets.
|
default Collection<AnnotationInstance> |
annotations(String name)
Returns the annotation instances with given name declared on this annotation target and nested annotation targets.
|
default Collection<AnnotationInstance> |
annotationsWithRepeatable(Class<? extends Annotation> clazz,
IndexView index)
Returns the annotation instances of given type declared on this annotation target and nested annotation targets.
|
Collection<AnnotationInstance> |
annotationsWithRepeatable(DotName name,
IndexView index)
Returns the annotation instances with given name declared on this annotation target and nested annotation targets.
|
default Collection<AnnotationInstance> |
annotationsWithRepeatable(String name,
IndexView index)
Returns the annotation instances with given name declared on this annotation target and nested annotation targets.
|
ClassInfo |
asClass()
Casts and returns this target as a
ClassInfo if it is of kind CLASS |
FieldInfo |
asField()
Casts and returns this target as a
FieldInfo if it is of kind FIELD |
MethodInfo |
asMethod()
Casts and returns this target as a
MethodInfo if it is of kind METHOD |
MethodParameterInfo |
asMethodParameter()
Casts and returns this target as a
MethodParameterInfo if it is of kind METHOD_PARAMETER |
RecordComponentInfo |
asRecordComponent()
Casts and returns this target as a
RecordComponentInfo if it is of kind RECORD_COMPONENT |
TypeTarget |
asType()
Casts and returns this target as a
TypeTarget if it is of kind TYPE |
default AnnotationInstance |
declaredAnnotation(Class<? extends Annotation> clazz)
Returns the annotation instance of given type declared on this annotation target.
|
AnnotationInstance |
declaredAnnotation(DotName name)
Returns the annotation instance with given name declared on this annotation target.
|
default AnnotationInstance |
declaredAnnotation(String name)
Returns the annotation instance with given name declared on this annotation target.
|
Collection<AnnotationInstance> |
declaredAnnotations()
Returns the annotation instances declared on this annotation target.
|
default Collection<AnnotationInstance> |
declaredAnnotationsWithRepeatable(Class<? extends Annotation> clazz,
IndexView index)
Returns the annotation instances of given type declared on this annotation target.
|
Collection<AnnotationInstance> |
declaredAnnotationsWithRepeatable(DotName name,
IndexView index)
Returns the annotation instances with given name declared on this annotation target.
|
default Collection<AnnotationInstance> |
declaredAnnotationsWithRepeatable(String name,
IndexView index)
Returns the annotation instances with given name declared on this annotation target.
|
default boolean |
hasAnnotation(Class<? extends Annotation> clazz)
Returns whether an annotation instance of given type is declared on this annotation target or any of its
nested annotation targets.
|
boolean |
hasAnnotation(DotName name)
Returns whether an annotation instance with given name is declared on this annotation target or any of its
nested annotation targets.
|
default boolean |
hasAnnotation(String name)
Returns whether an annotation instance with given name is declared on this annotation target or any of its
nested annotation targets.
|
default boolean |
hasDeclaredAnnotation(Class<? extends Annotation> clazz)
Returns whether an annotation instance of given type is declared on this annotation target.
|
boolean |
hasDeclaredAnnotation(DotName name)
Returns whether an annotation instance with given name is declared on this annotation target.
|
default boolean |
hasDeclaredAnnotation(String name)
Returns whether an annotation instance with given name is declared on this annotation target.
|
AnnotationTarget.Kind |
kind()
Returns the kind of object this target represents.
|
AnnotationTarget.Kind kind()
ClassInfo asClass()
ClassInfo if it is of kind CLASSFieldInfo asField()
FieldInfo if it is of kind FIELDMethodInfo asMethod()
MethodInfo if it is of kind METHODMethodParameterInfo asMethodParameter()
MethodParameterInfo if it is of kind METHOD_PARAMETERTypeTarget asType()
TypeTarget if it is of kind TYPERecordComponentInfo asRecordComponent()
RecordComponentInfo if it is of kind RECORD_COMPONENTboolean hasAnnotation(DotName name)
name - name of the annotation type to look for, must not be nulltrue if the annotation is present, false otherwiseannotation(DotName)default boolean hasAnnotation(String name)
name - name of the annotation type to look for, must not be nulltrue if the annotation is present, false otherwiseannotation(DotName)default boolean hasAnnotation(Class<? extends Annotation> clazz)
clazz - the annotation type to look for, must not be nulltrue if the annotation is present, false otherwiseannotation(DotName)AnnotationInstance annotation(DotName name)
target() method of the returned annotation instance may be used to determine
the exact location of the annotation instance.
In case an annotation with given name occurs more than once, the result of this method is not deterministic.
For such situations, annotations(DotName) is preferable.
name - name of the annotation type to look for, must not be nullnull if not foundannotations(DotName)default AnnotationInstance annotation(String name)
target() method of the returned annotation instance may be used to determine
the exact location of the annotation instance.
In case an annotation with given name occurs more than once, the result of this method is not deterministic.
For such situations, annotations(DotName) is preferable.
name - name of the annotation type to look for, must not be nullnull if not foundannotations(DotName)default AnnotationInstance annotation(Class<? extends Annotation> clazz)
target() method of the returned annotation instance may be used to determine
the exact location of the annotation instance.
In case an annotation with given name occurs more than once, the result of this method is not deterministic.
For such situations, annotations(DotName) is preferable.
clazz - the annotation type to look for, must not be nullnull if not foundannotations(DotName)Collection<AnnotationInstance> annotations(DotName name)
target() method of the returned annotation instances may be used to determine the exact location
of the respective annotation instance.name - name of the annotation type, must not be nullnullannotationsWithRepeatable(DotName, IndexView),
annotations()default Collection<AnnotationInstance> annotations(String name)
target() method of the returned annotation instances may be used to determine the exact location
of the respective annotation instance.name - name of the annotation type, must not be nullnullannotationsWithRepeatable(DotName, IndexView),
annotations()default Collection<AnnotationInstance> annotations(Class<? extends Annotation> clazz)
target() method of the returned annotation instances may be used to determine the exact location
of the respective annotation instance.clazz - the annotation type, must not be nullnullannotationsWithRepeatable(DotName, IndexView),
annotations()Collection<AnnotationInstance> annotationsWithRepeatable(DotName name, IndexView index)
target() method of the returned annotation instances may be used to determine the exact location
of the respective annotation instance.
If the specified annotation is repeatable, the result also contains all values from the container annotation
instance. In this case, the AnnotationInstance.target() returns the target of the container annotation
instance.
name - name of the annotation type, must not be nullindex - index used to obtain the annotation type, must not be nullnullIllegalArgumentException - if the index is null, if the index does not contain the annotation type
or if name does not identify an annotation typeannotations(DotName),
annotations()default Collection<AnnotationInstance> annotationsWithRepeatable(String name, IndexView index)
target() method of the returned annotation instances may be used to determine the exact location
of the respective annotation instance.
If the specified annotation is repeatable, the result also contains all values from the container annotation
instance. In this case, the AnnotationInstance.target() returns the target of the container annotation
instance.
name - name of the annotation type, must not be nullindex - index used to obtain the annotation type, must not be nullnullIllegalArgumentException - if the index is null, if the index does not contain the annotation type
or if name does not identify an annotation typeannotations(DotName),
annotations()default Collection<AnnotationInstance> annotationsWithRepeatable(Class<? extends Annotation> clazz, IndexView index)
target() method of the returned annotation instances may be used to determine the exact location
of the respective annotation instance.
If the specified annotation is repeatable, the result also contains all values from the container annotation
instance. In this case, the AnnotationInstance.target() returns the target of the container annotation
instance.
clazz - the annotation type, must not be nullindex - index used to obtain the annotation type, must not be nullnullIllegalArgumentException - if the index is null, if the index does not contain the annotation type
or if name does not identify an annotation typeannotations(DotName),
annotations()Collection<AnnotationInstance> annotations()
target() method of the returned annotation instances may be used to determine the exact location
of the respective annotation instance.nullboolean hasDeclaredAnnotation(DotName name)
Unlike hasAnnotation(DotName), this method ignores annotations declared on nested annotation targets.
name - name of the annotation type to look for, must not be nulltrue if the annotation is present, false otherwisehasAnnotation(DotName)default boolean hasDeclaredAnnotation(String name)
Unlike hasAnnotation(DotName), this method ignores annotations declared on nested annotation targets.
name - name of the annotation type to look for, must not be nulltrue if the annotation is present, false otherwisehasAnnotation(DotName)default boolean hasDeclaredAnnotation(Class<? extends Annotation> clazz)
Unlike hasAnnotation(DotName), this method ignores annotations declared on nested annotation targets.
clazz - the annotation type to look for, must not be nulltrue if the annotation is present, false otherwisehasAnnotation(DotName)AnnotationInstance declaredAnnotation(DotName name)
Unlike annotation(DotName), this method doesn't return annotations declared on nested annotation targets.
name - name of the annotation type to look for, must not be nullnull if not foundannotation(DotName)default AnnotationInstance declaredAnnotation(String name)
Unlike annotation(DotName), this method doesn't return annotations declared on nested annotation targets.
name - name of the annotation type to look for, must not be nullnull if not foundannotation(DotName)default AnnotationInstance declaredAnnotation(Class<? extends Annotation> clazz)
Unlike annotation(DotName), this method doesn't return annotations declared on nested annotation targets.
clazz - the annotation type to look for, must not be nullnull if not foundannotation(DotName)Collection<AnnotationInstance> declaredAnnotationsWithRepeatable(DotName name, IndexView index)
If the specified annotation is repeatable, the result also contains all values from the container annotation
instance. In this case, the AnnotationInstance.target() returns the target of the container annotation
instance.
Unlike annotationsWithRepeatable(DotName, IndexView), this method doesn't return annotations
declared on nested annotation targets.
name - name of the annotation type, must not be nullindex - index used to obtain the annotation type, must not be nullnullIllegalArgumentException - if the index is null, if the index does not contain the annotation type
or if name does not identify an annotation typeannotationsWithRepeatable(DotName, IndexView)default Collection<AnnotationInstance> declaredAnnotationsWithRepeatable(String name, IndexView index)
If the specified annotation is repeatable, the result also contains all values from the container annotation
instance. In this case, the AnnotationInstance.target() returns the target of the container annotation
instance.
Unlike annotationsWithRepeatable(DotName, IndexView), this method doesn't return annotations
declared on nested annotation targets.
name - name of the annotation type, must not be nullindex - index used to obtain the annotation type, must not be nullnullIllegalArgumentException - if the index is null, if the index does not contain the annotation type
or if name does not identify an annotation typeannotationsWithRepeatable(DotName, IndexView)default Collection<AnnotationInstance> declaredAnnotationsWithRepeatable(Class<? extends Annotation> clazz, IndexView index)
If the specified annotation is repeatable, the result also contains all values from the container annotation
instance. In this case, the AnnotationInstance.target() returns the target of the container annotation
instance.
Unlike annotationsWithRepeatable(DotName, IndexView), this method doesn't return annotations
declared on nested annotation targets.
clazz - the annotation type, must not be nullindex - index used to obtain the annotation type, must not be nullnullIllegalArgumentException - if the index is null, if the index does not contain the annotation type
or if name does not identify an annotation typeannotationsWithRepeatable(DotName, IndexView)Collection<AnnotationInstance> declaredAnnotations()
Unlike annotations(), this method doesn't return annotations declared on nested annotation targets.
nullannotations()Copyright © 2018–2022. All rights reserved.