Top Description Inners Methods
org.jboss.jandex

public Interface AnnotationTarget

Known Direct Subinterfaces
org.jboss.jandex.Declaration
Known Direct Implementers
org.jboss.jandex.TypeTarget
Imports
java.lang.annotation.Annotation, java.util.Collection

Represents an object that can be a target of an annotation.

Overall, two distinct kinds of annotation targets exist: declarations and types. To refer to declarations only, the Declaration interface may be used.

Author
Jason T. Greene
See Also
Declaration, TypeTarget

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static enum
AnnotationTarget.Kind

Specifies the kind of object a target represents.

Method Summary

Modifier and TypeMethod and Description
public AnnotationInstance

Returns:

the annotation instance, or null if not found
annotation
(DotName
name of the annotation type to look for, must not be null
name
)

Returns the annotation instance with given name declared on this annotation target or any of its nested annotation targets.

public default AnnotationInstance

Returns:

the annotation instance, or null if not found
annotation
(String
name of the annotation type to look for, must not be null
name
)

Returns the annotation instance with given name declared on this annotation target or any of its nested annotation targets.

public default AnnotationInstance

Returns:

the annotation instance, or null if not found
annotation
(Class<? extends Annotation>
the annotation type to look for, must not be null
clazz
)

Returns the annotation instance of given type declared on this annotation target or any of its nested annotation targets.

public Collection<AnnotationInstance>

Returns:

immutable collection of annotation instances, never null
annotations
(DotName
name of the annotation type, must not be null
name
)

Returns the annotation instances with given name declared on this annotation target and nested annotation targets.

public default Collection<AnnotationInstance>

Returns:

immutable collection of annotation instances, never null
annotations
(String
name of the annotation type, must not be null
name
)

Returns the annotation instances with given name declared on this annotation target and nested annotation targets.

public default Collection<AnnotationInstance>

Returns:

immutable collection of annotation instances, never null
annotations
(Class<? extends Annotation>
the annotation type, must not be null
clazz
)

Returns the annotation instances of given type declared on this annotation target and nested annotation targets.

public Collection<AnnotationInstance>

Returns:

immutable collection of annotation instances, never null
annotations
()

Returns the annotation instances declared on this annotation target and nested annotation targets.

public Collection<AnnotationInstance>

Returns:

immutable collection of annotation instances, never null
annotationsWithRepeatable
(DotName
name of the annotation type, must not be null
name
,
IndexView
index used to obtain the annotation type, must not be null
index
)

Returns the annotation instances with given name declared on this annotation target and nested annotation targets.

public default Collection<AnnotationInstance>

Returns:

immutable collection of annotation instances, never null
annotationsWithRepeatable
(String
name of the annotation type, must not be null
name
,
IndexView
index used to obtain the annotation type, must not be null
index
)

Returns the annotation instances with given name declared on this annotation target and nested annotation targets.

public default Collection<AnnotationInstance>

Returns:

immutable collection of annotation instances, never null
annotationsWithRepeatable
(Class<? extends Annotation>
the annotation type, must not be null
clazz
,
IndexView
index used to obtain the annotation type, must not be null
index
)

Returns the annotation instances of given type declared on this annotation target and nested annotation targets.

public ClassInfo

Returns:

this instance cast to a class
asClass
()

Casts and returns this target as a ClassInfo if it is of kind CLASS

public Declaration

Returns:

this instance cast to a declaration
asDeclaration
()

Casts and returns this annotation target as a Declaration if it is a declaration.

public FieldInfo

Returns:

this instance cast to a field
asField
()

Casts and returns this target as a FieldInfo if it is of kind FIELD

public MethodInfo

Returns:

this instance cast to a method
asMethod
()

Casts and returns this target as a MethodInfo if it is of kind METHOD

public MethodParameterInfo

Returns:

this instance cast to a method parameter
asMethodParameter
()

Casts and returns this target as a MethodParameterInfo if it is of kind METHOD_PARAMETER

public RecordComponentInfo

Returns:

this instance cast to a record component
asRecordComponent
()

Casts and returns this target as a RecordComponentInfo if it is of kind RECORD_COMPONENT

public TypeTarget

Returns:

this instance cast to a type target
asType
()

Casts and returns this target as a TypeTarget if it is of kind TYPE

public AnnotationInstance

Returns:

the annotation instance, or null if not found
declaredAnnotation
(DotName
name of the annotation type to look for, must not be null
name
)

Returns the annotation instance with given name declared on this annotation target.

public default AnnotationInstance

Returns:

the annotation instance, or null if not found
declaredAnnotation
(String
name of the annotation type to look for, must not be null
name
)

Returns the annotation instance with given name declared on this annotation target.

public default AnnotationInstance

Returns:

the annotation instance, or null if not found
declaredAnnotation
(Class<? extends Annotation>
the annotation type to look for, must not be null
clazz
)

Returns the annotation instance of given type declared on this annotation target.

public Collection<AnnotationInstance>

Returns:

immutable collection of annotation instances, never null
declaredAnnotations
()

Returns the annotation instances declared on this annotation target.

public Collection<AnnotationInstance>

Returns:

immutable collection of annotation instances, never null
declaredAnnotationsWithRepeatable
(DotName
name of the annotation type, must not be null
name
,
IndexView
index used to obtain the annotation type, must not be null
index
)

Returns the annotation instances with given name declared on this annotation target.

public default Collection<AnnotationInstance>

Returns:

immutable collection of annotation instances, never null
declaredAnnotationsWithRepeatable
(String
name of the annotation type, must not be null
name
,
IndexView
index used to obtain the annotation type, must not be null
index
)

Returns the annotation instances with given name declared on this annotation target.

public default Collection<AnnotationInstance>

Returns:

immutable collection of annotation instances, never null
declaredAnnotationsWithRepeatable
(Class<? extends Annotation>
the annotation type, must not be null
clazz
,
IndexView
index used to obtain the annotation type, must not be null
index
)

Returns the annotation instances of given type declared on this annotation target.

public boolean

Returns:

true if the annotation is present, false otherwise
hasAnnotation
(DotName
name of the annotation type to look for, must not be null
name
)

Returns whether an annotation instance with given name is declared on this annotation target or any of its nested annotation targets.

public default boolean

Returns:

true if the annotation is present, false otherwise
hasAnnotation
(String
name of the annotation type to look for, must not be null
name
)

Returns whether an annotation instance with given name is declared on this annotation target or any of its nested annotation targets.

public default boolean

Returns:

true if the annotation is present, false otherwise
hasAnnotation
(Class<? extends Annotation>
the annotation type to look for, must not be null
clazz
)

Returns whether an annotation instance of given type is declared on this annotation target or any of its nested annotation targets.

public boolean

Returns:

true if the annotation is present, false otherwise
hasDeclaredAnnotation
(DotName
name of the annotation type to look for, must not be null
name
)

Returns whether an annotation instance with given name is declared on this annotation target.

public default boolean

Returns:

true if the annotation is present, false otherwise
hasDeclaredAnnotation
(String
name of the annotation type to look for, must not be null
name
)

Returns whether an annotation instance with given name is declared on this annotation target.

public default boolean

Returns:

true if the annotation is present, false otherwise
hasDeclaredAnnotation
(Class<? extends Annotation>
the annotation type to look for, must not be null
clazz
)

Returns whether an annotation instance of given type is declared on this annotation target.

public boolean

Returns:

whether this annotation target is a declaration
isDeclaration
()

Returns whether this annotation target is a declaration.

public AnnotationTarget.Kind

Returns:

the target kind.
kind
()

Returns the kind of object this target represents.

Method Detail

annotationback to summary
public AnnotationInstance annotation(DotName name)

Returns the annotation instance with given name declared on this annotation target or any of its nested annotation targets. The 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.

Parameters
name:DotName

name of the annotation type to look for, must not be null

Returns:AnnotationInstance

the annotation instance, or null if not found

Since
3.0
See Also
annotations(DotName)
annotationback to summary
public default AnnotationInstance annotation(String name)

Returns the annotation instance with given name declared on this annotation target or any of its nested annotation targets. The 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.

Parameters
name:String

name of the annotation type to look for, must not be null

Returns:AnnotationInstance

the annotation instance, or null if not found

Since
3.0
See Also
annotations(DotName)
annotationback to summary
public 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. The 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.

Parameters
clazz:Class<? extends Annotation>

the annotation type to look for, must not be null

Returns:AnnotationInstance

the annotation instance, or null if not found

Since
3.0
See Also
annotations(DotName)
annotationsback to summary
public Collection<AnnotationInstance> annotations(DotName name)

Returns the annotation instances with given name declared on this annotation target and nested annotation targets. The target() method of the returned annotation instances may be used to determine the exact location of the respective annotation instance.

Parameters
name:DotName

name of the annotation type, must not be null

Returns:Collection<AnnotationInstance>

immutable collection of annotation instances, never null

Since
3.0
See Also
annotationsWithRepeatable(DotName, IndexView), annotations()
annotationsback to summary
public default Collection<AnnotationInstance> annotations(String name)

Returns the annotation instances with given name declared on this annotation target and nested annotation targets. The target() method of the returned annotation instances may be used to determine the exact location of the respective annotation instance.

Parameters
name:String

name of the annotation type, must not be null

Returns:Collection<AnnotationInstance>

immutable collection of annotation instances, never null

Since
3.0
See Also
annotationsWithRepeatable(DotName, IndexView), annotations()
annotationsback to summary
public default Collection<AnnotationInstance> annotations(Class<? extends Annotation> clazz)

Returns the annotation instances of given type declared on this annotation target and nested annotation targets. The target() method of the returned annotation instances may be used to determine the exact location of the respective annotation instance.

Parameters
clazz:Class<? extends Annotation>

the annotation type, must not be null

Returns:Collection<AnnotationInstance>

immutable collection of annotation instances, never null

Since
3.0
See Also
annotationsWithRepeatable(DotName, IndexView), annotations()
annotationsback to summary
public Collection<AnnotationInstance> annotations()

Returns the annotation instances declared on this annotation target and nested annotation targets. The target() method of the returned annotation instances may be used to determine the exact location of the respective annotation instance.

Returns:Collection<AnnotationInstance>

immutable collection of annotation instances, never null

Since
3.0
annotationsWithRepeatableback to summary
public Collection<AnnotationInstance> annotationsWithRepeatable(DotName name, IndexView index)

Returns the annotation instances with given name declared on this annotation target and nested annotation targets. The 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.

Parameters
name:DotName

name of the annotation type, must not be null

index:IndexView

index used to obtain the annotation type, must not be null

Returns:Collection<AnnotationInstance>

immutable collection of annotation instances, never null

Exceptions
IllegalArgumentException:
if the index is null, if the index does not contain the annotation type or if name does not identify an annotation type
Since
3.0
See Also
annotations(DotName), annotations()
annotationsWithRepeatableback to summary
public default Collection<AnnotationInstance> annotationsWithRepeatable(String name, IndexView index)

Returns the annotation instances with given name declared on this annotation target and nested annotation targets. The 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.

Parameters
name:String

name of the annotation type, must not be null

index:IndexView

index used to obtain the annotation type, must not be null

Returns:Collection<AnnotationInstance>

immutable collection of annotation instances, never null

Exceptions
IllegalArgumentException:
if the index is null, if the index does not contain the annotation type or if name does not identify an annotation type
Since
3.0
See Also
annotations(DotName), annotations()
annotationsWithRepeatableback to summary
public 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. The 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.

Parameters
clazz:Class<? extends Annotation>

the annotation type, must not be null

index:IndexView

index used to obtain the annotation type, must not be null

Returns:Collection<AnnotationInstance>

immutable collection of annotation instances, never null

Exceptions
IllegalArgumentException:
if the index is null, if the index does not contain the annotation type or if name does not identify an annotation type
Since
3.0
See Also
annotations(DotName), annotations()
asClassback to summary
public ClassInfo asClass()

Casts and returns this target as a ClassInfo if it is of kind CLASS

Returns:ClassInfo

this instance cast to a class

Since
2.0
asDeclarationback to summary
public Declaration asDeclaration()

Casts and returns this annotation target as a Declaration if it is a declaration.

Returns:Declaration

this instance cast to a declaration

Since
3.1.0
asFieldback to summary
public FieldInfo asField()

Casts and returns this target as a FieldInfo if it is of kind FIELD

Returns:FieldInfo

this instance cast to a field

Since
2.0
asMethodback to summary
public MethodInfo asMethod()

Casts and returns this target as a MethodInfo if it is of kind METHOD

Returns:MethodInfo

this instance cast to a method

Since
2.0
asMethodParameterback to summary
public MethodParameterInfo asMethodParameter()

Casts and returns this target as a MethodParameterInfo if it is of kind METHOD_PARAMETER

Returns:MethodParameterInfo

this instance cast to a method parameter

Since
2.0
asRecordComponentback to summary
public RecordComponentInfo asRecordComponent()

Casts and returns this target as a RecordComponentInfo if it is of kind RECORD_COMPONENT

Returns:RecordComponentInfo

this instance cast to a record component

Since
2.4
asTypeback to summary
public TypeTarget asType()

Casts and returns this target as a TypeTarget if it is of kind TYPE

Returns:TypeTarget

this instance cast to a type target

Since
2.0
declaredAnnotationback to summary
public AnnotationInstance declaredAnnotation(DotName name)

Returns the annotation instance with given name declared on this annotation target.

Unlike annotation(DotName), this method doesn't return annotations declared on nested annotation targets.

Parameters
name:DotName

name of the annotation type to look for, must not be null

Returns:AnnotationInstance

the annotation instance, or null if not found

Since
3.0
See Also
annotation(DotName)
declaredAnnotationback to summary
public default AnnotationInstance declaredAnnotation(String name)

Returns the annotation instance with given name declared on this annotation target.

Unlike annotation(DotName), this method doesn't return annotations declared on nested annotation targets.

Parameters
name:String

name of the annotation type to look for, must not be null

Returns:AnnotationInstance

the annotation instance, or null if not found

Since
3.0
See Also
annotation(DotName)
declaredAnnotationback to summary
public default AnnotationInstance declaredAnnotation(Class<? extends Annotation> clazz)

Returns the annotation instance of given type declared on this annotation target.

Unlike annotation(DotName), this method doesn't return annotations declared on nested annotation targets.

Parameters
clazz:Class<? extends Annotation>

the annotation type to look for, must not be null

Returns:AnnotationInstance

the annotation instance, or null if not found

Since
3.0
See Also
annotation(DotName)
declaredAnnotationsback to summary
public Collection<AnnotationInstance> declaredAnnotations()

Returns the annotation instances declared on this annotation target.

Unlike annotations(), this method doesn't return annotations declared on nested annotation targets.

Returns:Collection<AnnotationInstance>

immutable collection of annotation instances, never null

Since
3.0
See Also
annotations()
declaredAnnotationsWithRepeatableback to summary
public Collection<AnnotationInstance> declaredAnnotationsWithRepeatable(DotName name, IndexView index)

Returns the annotation instances with given name declared on this annotation target.

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.

Parameters
name:DotName

name of the annotation type, must not be null

index:IndexView

index used to obtain the annotation type, must not be null

Returns:Collection<AnnotationInstance>

immutable collection of annotation instances, never null

Exceptions
IllegalArgumentException:
if the index is null, if the index does not contain the annotation type or if name does not identify an annotation type
Since
3.0
See Also
annotationsWithRepeatable(DotName, IndexView)
declaredAnnotationsWithRepeatableback to summary
public default Collection<AnnotationInstance> declaredAnnotationsWithRepeatable(String name, IndexView index)

Returns the annotation instances with given name declared on this annotation target.

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.

Parameters
name:String

name of the annotation type, must not be null

index:IndexView

index used to obtain the annotation type, must not be null

Returns:Collection<AnnotationInstance>

immutable collection of annotation instances, never null

Exceptions
IllegalArgumentException:
if the index is null, if the index does not contain the annotation type or if name does not identify an annotation type
Since
3.0
See Also
annotationsWithRepeatable(DotName, IndexView)
declaredAnnotationsWithRepeatableback to summary
public default Collection<AnnotationInstance> declaredAnnotationsWithRepeatable(Class<? extends Annotation> clazz, IndexView index)

Returns the annotation instances of given type declared on this annotation target.

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.

Parameters
clazz:Class<? extends Annotation>

the annotation type, must not be null

index:IndexView

index used to obtain the annotation type, must not be null

Returns:Collection<AnnotationInstance>

immutable collection of annotation instances, never null

Exceptions
IllegalArgumentException:
if the index is null, if the index does not contain the annotation type or if name does not identify an annotation type
Since
3.0
See Also
annotationsWithRepeatable(DotName, IndexView)
hasAnnotationback to summary
public 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.

Parameters
name:DotName

name of the annotation type to look for, must not be null

Returns:boolean

true if the annotation is present, false otherwise

Since
3.0
See Also
annotation(DotName)
hasAnnotationback to summary
public 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.

Parameters
name:String

name of the annotation type to look for, must not be null

Returns:boolean

true if the annotation is present, false otherwise

Since
3.0
See Also
annotation(DotName)
hasAnnotationback to summary
public 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.

Parameters
clazz:Class<? extends Annotation>

the annotation type to look for, must not be null

Returns:boolean

true if the annotation is present, false otherwise

Since
3.0
See Also
annotation(DotName)
hasDeclaredAnnotationback to summary
public boolean hasDeclaredAnnotation(DotName name)

Returns whether an annotation instance with given name is declared on this annotation target.

Unlike hasAnnotation(DotName), this method ignores annotations declared on nested annotation targets.

Parameters
name:DotName

name of the annotation type to look for, must not be null

Returns:boolean

true if the annotation is present, false otherwise

Since
3.0
See Also
hasAnnotation(DotName)
hasDeclaredAnnotationback to summary
public default boolean hasDeclaredAnnotation(String name)

Returns whether an annotation instance with given name is declared on this annotation target.

Unlike hasAnnotation(DotName), this method ignores annotations declared on nested annotation targets.

Parameters
name:String

name of the annotation type to look for, must not be null

Returns:boolean

true if the annotation is present, false otherwise

Since
3.0
See Also
hasAnnotation(DotName)
hasDeclaredAnnotationback to summary
public default boolean hasDeclaredAnnotation(Class<? extends Annotation> clazz)

Returns whether an annotation instance of given type is declared on this annotation target.

Unlike hasAnnotation(DotName), this method ignores annotations declared on nested annotation targets.

Parameters
clazz:Class<? extends Annotation>

the annotation type to look for, must not be null

Returns:boolean

true if the annotation is present, false otherwise

Since
3.0
See Also
hasAnnotation(DotName)
isDeclarationback to summary
public boolean isDeclaration()

Returns whether this annotation target is a declaration.

Returns:boolean

whether this annotation target is a declaration

Since
3.1.0
kindback to summary
public AnnotationTarget.Kind kind()

Returns the kind of object this target represents.

Returns:AnnotationTarget.Kind

the target kind.

Since
2.0
org.jboss.jandex back to summary

public final Enum AnnotationTarget.Kind

extends Enum<AnnotationTarget.Kind>
Class Inheritance

Specifies the kind of object a target represents.

Field Summary

Modifier and TypeField and Description
public static final AnnotationTarget.Kind
public static final AnnotationTarget.Kind
public static final AnnotationTarget.Kind
public static final AnnotationTarget.Kind
public static final AnnotationTarget.Kind
public static final AnnotationTarget.Kind

Constructor Summary

AccessConstructor and Description
private
Kind()

Method Summary

Modifier and TypeMethod and Description
public static AnnotationTarget.Kind
public static AnnotationTarget.Kind[]
Inherited from java.lang.Enum:
clonecompareTodescribeConstableequalsfinalizegetDeclaringClasshashCodenameordinaltoStringvalueOf

Field Detail

CLASSback to summary
public static final AnnotationTarget.Kind CLASS

An object of type org.jboss.jandex.ClassInfo

FIELDback to summary
public static final AnnotationTarget.Kind FIELD

An object of type org.jboss.jandex.FieldInfo

METHODback to summary
public static final AnnotationTarget.Kind METHOD

An object of type org.jboss.jandex.MethodInfo

METHOD_PARAMETERback to summary
public static final AnnotationTarget.Kind METHOD_PARAMETER

An object of type org.jboss.jandex.MethodParameterInfo

RECORD_COMPONENTback to summary
public static final AnnotationTarget.Kind RECORD_COMPONENT

An object of type org.jboss.jandex.RecordComponentInfo

Since
2.4
TYPEback to summary
public static final AnnotationTarget.Kind TYPE

An object of type org.jboss.jandex.TypeTarget

Constructor Detail

Kindback to summary
private Kind()

Method Detail

valueOfback to summary
public static AnnotationTarget.Kind valueOf(String name)
valuesback to summary
public static AnnotationTarget.Kind[] values()