Top Description Inners Fields Constructors Methods
org.jboss.jandex

public abstract Class TypeTarget

extends Object
implements AnnotationTarget
Class Inheritance
All Implemented Interfaces
org.jboss.jandex.AnnotationTarget
Known Direct Subclasses
org.jboss.jandex.EmptyTypeTarget, org.jboss.jandex.PositionBasedTypeTarget
Imports
java.util.Collections, .List

Represents a type that is the target of a type annotation. Type annotations can occur at any nesting level on any type declaration. For this reason, an enclosing target is provided, as well as other usage specific information to determine the starting point for locating the type.

It is expected that callers will traverse the full tree from the specified starting point, since this context is important in interpreting the meaning of the type annotation

Author
Jason T. Greene
Since
2.0
See Also
org.jboss.jandex.EmptyTypeTarget, org.jboss.jandex.ClassExtendsTypeTarget, org.jboss.jandex.MethodParameterTypeTarget, org.jboss.jandex.TypeParameterTypeTarget, org.jboss.jandex.TypeParameterBoundTypeTarget, org.jboss.jandex.ThrowsTypeTarget

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static enum
TypeTarget.Usage

Specifies a form of usage of a type annotation

Field Summary

Modifier and TypeField and Description
private final AnnotationTarget
private Type

Constructor Summary

AccessConstructor and Description
pack-priv
TypeTarget(AnnotationTarget enclosingTarget, Type target)

pack-priv
TypeTarget(AnnotationTarget enclosingTarget)

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
)

Implements org.jboss.jandex.AnnotationTarget.annotation.

Returns the annotation instance with given name declared on this type usage.
public List<AnnotationInstance>

Returns:

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

Implements org.jboss.jandex.AnnotationTarget.annotations.

Returns the annotation instances with given name declared on this type usage.
public List<AnnotationInstance>

Returns:

immutable list of annotation instances, never null
annotations
()

Implements org.jboss.jandex.AnnotationTarget.annotations.

Returns the annotation instances declared on this type usage.
public List<AnnotationInstance>

Returns:

immutable list 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
)

Implements org.jboss.jandex.AnnotationTarget.annotationsWithRepeatable.

Returns the annotation instances with given name declared on this type usage.
public final ClassInfo
asClass()

Implements org.jboss.jandex.AnnotationTarget.asClass.

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

Returns:

an instance of ClassExtendsTypeTarget
asClassExtends
()

Casts and returns this type target as a ClassExtendsTypeTarget.

public Declaration
asDeclaration()

Implements org.jboss.jandex.AnnotationTarget.asDeclaration.

Casts and returns this annotation target as a Declaration if it is a declaration.
public EmptyTypeTarget
public final FieldInfo
asField()

Implements org.jboss.jandex.AnnotationTarget.asField.

Casts and returns this target as a FieldInfo if it is of kind FIELD
public final MethodInfo
asMethod()

Implements org.jboss.jandex.AnnotationTarget.asMethod.

Casts and returns this target as a MethodInfo if it is of kind METHOD
public final MethodParameterInfo
asMethodParameter()

Implements org.jboss.jandex.AnnotationTarget.asMethodParameter.

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

Returns:

an instance of MethodParameterTypeTarget
asMethodParameterType
()

Casts and returns this type target as a MethodParameterTypeTarget.

public final RecordComponentInfo
asRecordComponent()

Implements org.jboss.jandex.AnnotationTarget.asRecordComponent.

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

Returns:

an instance of ThrowsTypeTarget
asThrows
()

Casts and returns this type target as a ThrowsTypeTarget.

public final TypeTarget
asType()

Implements org.jboss.jandex.AnnotationTarget.asType.

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

Returns:

an instance of TypeParameterTypeTarget
asTypeParameter
()

Casts and returns this type target as a TypeParameterTypeTarget.

public TypeParameterBoundTypeTarget

Returns:

an instance of TypeParameterBoundTypeTarget
asTypeParameterBound
()

Casts and returns this type target as a TypeParameterBoundTypeTarget.

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
)

Implements org.jboss.jandex.AnnotationTarget.declaredAnnotation.

Returns the annotation instance with given name declared on this type usage.
public List<AnnotationInstance>

Returns:

immutable list of annotation instances, never null
declaredAnnotations
()

Implements org.jboss.jandex.AnnotationTarget.declaredAnnotations.

Returns the annotation instances declared on this type usage.
public List<AnnotationInstance>

Returns:

immutable list 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
)

Implements org.jboss.jandex.AnnotationTarget.declaredAnnotationsWithRepeatable.

Returns the annotation instances with given name declared on this type usage.
public AnnotationTarget

Returns:

the enclosing target
enclosingTarget
()

Returns the enclosing target that contains the type referred to by the target() method.

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
)

Implements org.jboss.jandex.AnnotationTarget.hasAnnotation.

Returns whether an annotation instance with given name is declared on this type usage.
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
)

Implements org.jboss.jandex.AnnotationTarget.hasDeclaredAnnotation.

Returns whether an annotation instance with given name is declared on this type usage.
public boolean
isDeclaration()

Implements org.jboss.jandex.AnnotationTarget.isDeclaration.

Returns whether this annotation target is a declaration.
public final AnnotationTarget.Kind
kind()

Implements org.jboss.jandex.AnnotationTarget.kind.

Returns the kind of object this target represents.
pack-priv void
setTarget(Type target)

public Type

Returns:

the type containing the respective annotation
target
()

Returns the type which contains the respective annotation.

public abstract TypeTarget.Usage

Returns:

the kind of usage of this type target
usage
()

Returns the kind of usage of this type target.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

enclosingTargetback to summary
private final AnnotationTarget enclosingTarget
targetback to summary
private Type target

Constructor Detail

TypeTargetback to summary
pack-priv TypeTarget(AnnotationTarget enclosingTarget, Type target)
TypeTargetback to summary
pack-priv TypeTarget(AnnotationTarget enclosingTarget)

Method Detail

annotationback to summary
public AnnotationInstance annotation(DotName name)

Implements org.jboss.jandex.AnnotationTarget.annotation.

Returns the annotation instance with given name declared on this type usage.

Note that unlike other AnnotationTargets, this method doesn't inspect nested annotation targets, even though array types, parameterized types, type variables and wildcard types may contain other types inside them. In other words, this method is equivalent to declaredAnnotation(DotName).

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

Annotations
@Override
Since
3.0
See Also
annotations(DotName)
annotationsback to summary
public List<AnnotationInstance> annotations(DotName name)

Implements org.jboss.jandex.AnnotationTarget.annotations.

Returns the annotation instances with given name declared on this type usage.

Note that unlike other AnnotationTargets, this method doesn't inspect nested annotation targets, even though array types, parameterized types, type variables and wildcard types may contain other types inside them. In other words, this method is equivalent to annotation(DotName) and declaredAnnotation(DotName), except it returns a list.

Parameters
name:DotName

name of the annotation type, must not be null

Returns:List<AnnotationInstance>

immutable list of annotation instances, never null

Annotations
@Override
Since
3.0
See Also
annotationsWithRepeatable(DotName, IndexView), annotations()
annotationsback to summary
public List<AnnotationInstance> annotations()

Implements org.jboss.jandex.AnnotationTarget.annotations.

Returns the annotation instances declared on this type usage.

Note that unlike other AnnotationTargets, this method doesn't inspect nested annotation targets, even though array types, parameterized types, type variables and wildcard types may contain other types inside them. In other words, this method is equivalent to declaredAnnotations().

Returns:List<AnnotationInstance>

immutable list of annotation instances, never null

Annotations
@Override
Since
3.0
annotationsWithRepeatableback to summary
public List<AnnotationInstance> annotationsWithRepeatable(DotName name, IndexView index)

Implements org.jboss.jandex.AnnotationTarget.annotationsWithRepeatable.

Returns the annotation instances with given name declared on this type usage.

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.

Note that unlike other AnnotationTargets, this method doesn't inspect nested annotation targets, even though array types, parameterized types, type variables and wildcard types may contain other types inside them. In other words, this method is equivalent to declaredAnnotationsWithRepeatable(DotName, IndexView).

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:List<AnnotationInstance>

immutable list of annotation instances, never null

Annotations
@Override
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 final ClassInfo asClass()

Implements org.jboss.jandex.AnnotationTarget.asClass.

Doc from org.jboss.jandex.AnnotationTarget.asClass.

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

Returns:ClassInfo

this instance cast to a class

Annotations
@Override
asClassExtendsback to summary
public ClassExtendsTypeTarget asClassExtends()

Casts and returns this type target as a ClassExtendsTypeTarget. If this type target is not a ClassExtendsTypeTarget, then an exception will be thrown.

Returns:ClassExtendsTypeTarget

an instance of ClassExtendsTypeTarget

Exceptions
IllegalArgumentException:
if this is not a ClassExtendsTypeTarget
asDeclarationback to summary
public Declaration asDeclaration()

Implements org.jboss.jandex.AnnotationTarget.asDeclaration.

Doc from org.jboss.jandex.AnnotationTarget.asDeclaration.

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

Returns:Declaration

this instance cast to a declaration

Annotations
@Override
asEmptyback to summary
public EmptyTypeTarget asEmpty()
asFieldback to summary
public final FieldInfo asField()

Implements org.jboss.jandex.AnnotationTarget.asField.

Doc from org.jboss.jandex.AnnotationTarget.asField.

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

Returns:FieldInfo

this instance cast to a field

Annotations
@Override
asMethodback to summary
public final MethodInfo asMethod()

Implements org.jboss.jandex.AnnotationTarget.asMethod.

Doc from org.jboss.jandex.AnnotationTarget.asMethod.

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

Returns:MethodInfo

this instance cast to a method

Annotations
@Override
asMethodParameterback to summary
public final MethodParameterInfo asMethodParameter()

Implements org.jboss.jandex.AnnotationTarget.asMethodParameter.

Doc from org.jboss.jandex.AnnotationTarget.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

Annotations
@Override
asMethodParameterTypeback to summary
public MethodParameterTypeTarget asMethodParameterType()

Casts and returns this type target as a MethodParameterTypeTarget. If this type target is not a MethodParameterTypeTarget, then an exception will be thrown.

Returns:MethodParameterTypeTarget

an instance of MethodParameterTypeTarget

Exceptions
IllegalArgumentException:
if this is not a MethodParameterTypeTarget
asRecordComponentback to summary
public final RecordComponentInfo asRecordComponent()

Implements org.jboss.jandex.AnnotationTarget.asRecordComponent.

Doc from org.jboss.jandex.AnnotationTarget.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

Annotations
@Override
asThrowsback to summary
public ThrowsTypeTarget asThrows()

Casts and returns this type target as a ThrowsTypeTarget. If this type target is not a ThrowsTypeTarget, then an exception will be thrown.

Returns:ThrowsTypeTarget

an instance of ThrowsTypeTarget

Exceptions
IllegalArgumentException:
if this is not a TypeParameterBoundTypeTarget
asTypeback to summary
public final TypeTarget asType()

Implements org.jboss.jandex.AnnotationTarget.asType.

Doc from org.jboss.jandex.AnnotationTarget.asType.

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

Returns:TypeTarget

this instance cast to a type target

Annotations
@Override
asTypeParameterback to summary
public TypeParameterTypeTarget asTypeParameter()

Casts and returns this type target as a TypeParameterTypeTarget. If this type target is not a TypeParameterTypeTarget, then an exception will be thrown.

Returns:TypeParameterTypeTarget

an instance of TypeParameterTypeTarget

Exceptions
IllegalArgumentException:
if this is not a TypeParameterTypeTarget
asTypeParameterBoundback to summary
public TypeParameterBoundTypeTarget asTypeParameterBound()

Casts and returns this type target as a TypeParameterBoundTypeTarget. If this type target is not a TypeParameterBoundTypeTarget, then an exception will be thrown.

Returns:TypeParameterBoundTypeTarget

an instance of TypeParameterBoundTypeTarget

Exceptions
IllegalArgumentException:
if this is not a TypeParameterBoundTypeTarget
declaredAnnotationback to summary
public AnnotationInstance declaredAnnotation(DotName name)

Implements org.jboss.jandex.AnnotationTarget.declaredAnnotation.

Returns the annotation instance with given name declared on this type usage.

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

Annotations
@Override
Since
3.0
See Also
annotation(DotName)
declaredAnnotationsback to summary
public List<AnnotationInstance> declaredAnnotations()

Implements org.jboss.jandex.AnnotationTarget.declaredAnnotations.

Returns the annotation instances declared on this type usage.

Returns:List<AnnotationInstance>

immutable list of annotation instances, never null

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

Implements org.jboss.jandex.AnnotationTarget.declaredAnnotationsWithRepeatable.

Returns the annotation instances with given name declared on this type usage.

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:List<AnnotationInstance>

immutable list of annotation instances, never null

Annotations
@Override
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)
enclosingTargetback to summary
public AnnotationTarget enclosingTarget()

Returns the enclosing target that contains the type referred to by the target() method.

Returns:AnnotationTarget

the enclosing target

hasAnnotationback to summary
public boolean hasAnnotation(DotName name)

Implements org.jboss.jandex.AnnotationTarget.hasAnnotation.

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

Note that unlike other AnnotationTargets, this method doesn't inspect nested annotation targets, even though array types, parameterized types, type variables and wildcard types may contain other types inside them. In other words, this method is equivalent to hasDeclaredAnnotation(DotName).

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

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

Implements org.jboss.jandex.AnnotationTarget.hasDeclaredAnnotation.

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

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

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

Implements org.jboss.jandex.AnnotationTarget.isDeclaration.

Doc from org.jboss.jandex.AnnotationTarget.isDeclaration.

Returns whether this annotation target is a declaration.

Returns:boolean

whether this annotation target is a declaration

Annotations
@Override
kindback to summary
public final AnnotationTarget.Kind kind()

Implements org.jboss.jandex.AnnotationTarget.kind.

Doc from org.jboss.jandex.AnnotationTarget.kind.

Returns the kind of object this target represents.

Returns:AnnotationTarget.Kind

the target kind.

Annotations
@Override
setTargetback to summary
pack-priv void setTarget(Type target)
targetback to summary
public Type target()

Returns the type which contains the respective annotation. In some cases this may be null (e.g. in the case of a bridge method, which erases type information so there is no target to map to)

Returns:Type

the type containing the respective annotation

usageback to summary
public abstract TypeTarget.Usage usage()

Returns the kind of usage of this type target. This allows a caller to use a switch statement as opposed to getClass() comparisons.

Returns:TypeTarget.Usage

the kind of usage of this type target

org.jboss.jandex back to summary

public final Enum TypeTarget.Usage

extends Enum<TypeTarget.Usage>
Class Inheritance

Specifies a form of usage of a type annotation

Field Summary

Modifier and TypeField and Description
public static final TypeTarget.Usage
CLASS_EXTENDS

Indicates a type annotation occurs within class' extends or implements clause

public static final TypeTarget.Usage
EMPTY

Indicates a type annotation occurs within a field, method receiver, or method return type

public static final TypeTarget.Usage
METHOD_PARAMETER

Indicates a type annotation occurs within a method parameter

public static final TypeTarget.Usage
THROWS

Indicates a type annotation occurs within the throws clause of a method

public static final TypeTarget.Usage
TYPE_PARAMETER

Indicates a type annotation occurs within a method or class type parameter

public static final TypeTarget.Usage
TYPE_PARAMETER_BOUND

Indicates a type annotation occurs within the bound of a method or class type parameter

Constructor Summary

AccessConstructor and Description
private

Method Summary

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

Field Detail

CLASS_EXTENDSback to summary
public static final TypeTarget.Usage CLASS_EXTENDS

Indicates a type annotation occurs within class' extends or implements clause

EMPTYback to summary
public static final TypeTarget.Usage EMPTY

Indicates a type annotation occurs within a field, method receiver, or method return type

METHOD_PARAMETERback to summary
public static final TypeTarget.Usage METHOD_PARAMETER

Indicates a type annotation occurs within a method parameter

THROWSback to summary
public static final TypeTarget.Usage THROWS

Indicates a type annotation occurs within the throws clause of a method

TYPE_PARAMETERback to summary
public static final TypeTarget.Usage TYPE_PARAMETER

Indicates a type annotation occurs within a method or class type parameter

TYPE_PARAMETER_BOUNDback to summary
public static final TypeTarget.Usage TYPE_PARAMETER_BOUND

Indicates a type annotation occurs within the bound of a method or class type parameter

Constructor Detail

Usageback to summary
private Usage()

Method Detail

valueOfback to summary
public static TypeTarget.Usage valueOf(String name)
valuesback to summary
public static TypeTarget.Usage[] values()