Package org.jboss.jandex
Class TypeTarget
java.lang.Object
org.jboss.jandex.TypeTarget
- All Implemented Interfaces:
AnnotationTarget
- Direct Known Subclasses:
EmptyTypeTarget
,PositionBasedTypeTarget
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
- Since:
- 2.0
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enum
Specifies a form of usage of a type annotationNested classes/interfaces inherited from interface org.jboss.jandex.AnnotationTarget
AnnotationTarget.Kind
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionTypeTarget
(AnnotationTarget enclosingTarget) TypeTarget
(AnnotationTarget enclosingTarget, Type target) -
Method Summary
Modifier and TypeMethodDescriptionfinal ClassInfo
asClass()
Casts and returns this target as aClassInfo
if it is of kindCLASS
Casts and returns this type target as aClassExtendsTypeTarget
.asEmpty()
final FieldInfo
asField()
Casts and returns this target as aFieldInfo
if it is of kindFIELD
final MethodInfo
asMethod()
Casts and returns this target as aMethodInfo
if it is of kindMETHOD
final MethodParameterInfo
Casts and returns this target as aMethodParameterInfo
if it is of kindMETHOD_PARAMETER
Casts and returns this type target as aMethodParameterTypeTarget
.Casts and returns this target as aRecordComponentInfo
if it is of kindRECORD_COMPONENT
asThrows()
Casts and returns this type target as aThrowsTypeTarget
.final TypeTarget
asType()
Casts and returns this target as aTypeTarget
if it is of kindTYPE
Casts and returns this type target as aTypeParameterTypeTarget
.Casts and returns this type target as aTypeParameterBoundTypeTarget
.Returns the enclosing target that contains the type referred to by thetarget()
method.final AnnotationTarget.Kind
kind()
Returns the kind of object this target represents.(package private) void
target()
Returns the type which contains the respective annotation.abstract TypeTarget.Usage
usage()
Returns the kind of usage of this type target.
-
Field Details
-
enclosingTarget
-
target
-
-
Constructor Details
-
TypeTarget
TypeTarget(AnnotationTarget enclosingTarget, Type target) -
TypeTarget
TypeTarget(AnnotationTarget enclosingTarget)
-
-
Method Details
-
setTarget
-
kind
Description copied from interface:AnnotationTarget
Returns the kind of object this target represents.- Specified by:
kind
in interfaceAnnotationTarget
- Returns:
- the target kind.
-
enclosingTarget
Returns the enclosing target that contains the type referred to by thetarget()
method.- Returns:
- the enclosing target
-
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:
- the type containing the respective annotation
-
usage
Returns the kind of usage of this type target. This allows a caller to use a switch statement as opposed togetClass()
comparisons.- Returns:
- the kind of usage of this type target
-
asEmpty
-
asClassExtends
Casts and returns this type target as aClassExtendsTypeTarget
. If this type target is not aClassExtendsTypeTarget
, then an exception will be thrown.- Returns:
- an instance of
ClassExtendsTypeTarget
- Throws:
IllegalArgumentException
- if this is not aClassExtendsTypeTarget
-
asMethodParameterType
Casts and returns this type target as aMethodParameterTypeTarget
. If this type target is not aMethodParameterTypeTarget
, then an exception will be thrown.- Returns:
- an instance of
MethodParameterTypeTarget
- Throws:
IllegalArgumentException
- if this is not aMethodParameterTypeTarget
-
asTypeParameter
Casts and returns this type target as aTypeParameterTypeTarget
. If this type target is not aTypeParameterTypeTarget
, then an exception will be thrown.- Returns:
- an instance of
TypeParameterTypeTarget
- Throws:
IllegalArgumentException
- if this is not aTypeParameterTypeTarget
-
asTypeParameterBound
Casts and returns this type target as aTypeParameterBoundTypeTarget
. If this type target is not aTypeParameterBoundTypeTarget
, then an exception will be thrown.- Returns:
- an instance of
TypeParameterBoundTypeTarget
- Throws:
IllegalArgumentException
- if this is not aTypeParameterBoundTypeTarget
-
asThrows
Casts and returns this type target as aThrowsTypeTarget
. If this type target is not aThrowsTypeTarget
, then an exception will be thrown.- Returns:
- an instance of
ThrowsTypeTarget
- Throws:
IllegalArgumentException
- if this is not aTypeParameterBoundTypeTarget
-
asClass
Description copied from interface:AnnotationTarget
Casts and returns this target as aClassInfo
if it is of kindCLASS
- Specified by:
asClass
in interfaceAnnotationTarget
- Returns:
- this instance cast to a class
-
asField
Description copied from interface:AnnotationTarget
Casts and returns this target as aFieldInfo
if it is of kindFIELD
- Specified by:
asField
in interfaceAnnotationTarget
- Returns:
- this instance cast to a field
-
asMethod
Description copied from interface:AnnotationTarget
Casts and returns this target as aMethodInfo
if it is of kindMETHOD
- Specified by:
asMethod
in interfaceAnnotationTarget
- Returns:
- this instance cast to a method
-
asMethodParameter
Description copied from interface:AnnotationTarget
Casts and returns this target as aMethodParameterInfo
if it is of kindMETHOD_PARAMETER
- Specified by:
asMethodParameter
in interfaceAnnotationTarget
- Returns:
- this instance cast to a method parameter
-
asType
Description copied from interface:AnnotationTarget
Casts and returns this target as aTypeTarget
if it is of kindTYPE
- Specified by:
asType
in interfaceAnnotationTarget
- Returns:
- this instance cast to a type target
-
asRecordComponent
Description copied from interface:AnnotationTarget
Casts and returns this target as aRecordComponentInfo
if it is of kindRECORD_COMPONENT
- Specified by:
asRecordComponent
in interfaceAnnotationTarget
- Returns:
- this instance cast to a record component
-