public abstract class TypeTarget extends Object implements AnnotationTarget
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
EmptyTypeTarget,
ClassExtendsTypeTarget,
MethodParameterTypeTarget,
TypeParameterTypeTarget,
TypeParameterBoundTypeTarget,
ThrowsTypeTarget| Modifier and Type | Class and Description |
|---|---|
static class |
TypeTarget.Usage
Specifies a form of usage of a type annotation
|
AnnotationTarget.Kind| Modifier and Type | Method and Description |
|---|---|
AnnotationInstance |
annotation(DotName name)
Returns the annotation instance with given name declared on this type usage.
|
List<AnnotationInstance> |
annotations()
Returns the annotation instances declared on this type usage.
|
List<AnnotationInstance> |
annotations(DotName name)
Returns the annotation instances with given name declared on this type usage.
|
List<AnnotationInstance> |
annotationsWithRepeatable(DotName name,
IndexView index)
Returns the annotation instances with given name declared on this type usage.
|
ClassInfo |
asClass()
Casts and returns this target as a
ClassInfo if it is of kind CLASS |
ClassExtendsTypeTarget |
asClassExtends()
Casts and returns this type target as a
ClassExtendsTypeTarget. |
EmptyTypeTarget |
asEmpty() |
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 |
MethodParameterTypeTarget |
asMethodParameterType()
Casts and returns this type target as a
MethodParameterTypeTarget. |
RecordComponentInfo |
asRecordComponent()
Casts and returns this target as a
RecordComponentInfo if it is of kind RECORD_COMPONENT |
ThrowsTypeTarget |
asThrows()
Casts and returns this type target as a
ThrowsTypeTarget. |
TypeTarget |
asType()
Casts and returns this target as a
TypeTarget if it is of kind TYPE |
TypeParameterTypeTarget |
asTypeParameter()
Casts and returns this type target as a
TypeParameterTypeTarget. |
TypeParameterBoundTypeTarget |
asTypeParameterBound()
Casts and returns this type target as a
TypeParameterBoundTypeTarget. |
AnnotationInstance |
declaredAnnotation(DotName name)
Returns the annotation instance with given name declared on this type usage.
|
List<AnnotationInstance> |
declaredAnnotations()
Returns the annotation instances declared on this type usage.
|
List<AnnotationInstance> |
declaredAnnotationsWithRepeatable(DotName name,
IndexView index)
Returns the annotation instances with given name declared on this type usage.
|
AnnotationTarget |
enclosingTarget()
Returns the enclosing target that contains the type referred to by the
target() method. |
boolean |
hasAnnotation(DotName name)
Returns whether an annotation instance with given name is declared on this type usage.
|
boolean |
hasDeclaredAnnotation(DotName name)
Returns whether an annotation instance with given name is declared on this type usage.
|
AnnotationTarget.Kind |
kind()
Returns the kind of object this target represents.
|
Type |
target()
Returns the type which contains the respective annotation.
|
abstract TypeTarget.Usage |
usage()
Returns the kind of usage of this type target.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitannotation, annotation, annotations, annotations, annotationsWithRepeatable, annotationsWithRepeatable, declaredAnnotation, declaredAnnotation, declaredAnnotationsWithRepeatable, declaredAnnotationsWithRepeatable, hasAnnotation, hasAnnotation, hasDeclaredAnnotation, hasDeclaredAnnotationpublic final AnnotationTarget.Kind kind()
AnnotationTargetkind in interface AnnotationTargetpublic AnnotationTarget enclosingTarget()
target() method.public Type target()
public abstract TypeTarget.Usage usage()
getClass() comparisons.public EmptyTypeTarget asEmpty()
public ClassExtendsTypeTarget asClassExtends()
ClassExtendsTypeTarget. If this type target
is not a ClassExtendsTypeTarget, then an exception will be thrown.ClassExtendsTypeTargetIllegalArgumentException - if this is not a ClassExtendsTypeTargetpublic MethodParameterTypeTarget asMethodParameterType()
MethodParameterTypeTarget. If this type target
is not a MethodParameterTypeTarget, then an exception will be thrown.MethodParameterTypeTargetIllegalArgumentException - if this is not a MethodParameterTypeTargetpublic TypeParameterTypeTarget asTypeParameter()
TypeParameterTypeTarget. If this type target
is not a TypeParameterTypeTarget, then an exception will be thrown.TypeParameterTypeTargetIllegalArgumentException - if this is not a TypeParameterTypeTargetpublic TypeParameterBoundTypeTarget asTypeParameterBound()
TypeParameterBoundTypeTarget. If this type target
is not a TypeParameterBoundTypeTarget, then an exception will be thrown.TypeParameterBoundTypeTargetIllegalArgumentException - if this is not a TypeParameterBoundTypeTargetpublic ThrowsTypeTarget asThrows()
ThrowsTypeTarget. If this type target
is not a ThrowsTypeTarget, then an exception will be thrown.ThrowsTypeTargetIllegalArgumentException - if this is not a TypeParameterBoundTypeTargetpublic final ClassInfo asClass()
AnnotationTargetClassInfo if it is of kind CLASSasClass in interface AnnotationTargetpublic final FieldInfo asField()
AnnotationTargetFieldInfo if it is of kind FIELDasField in interface AnnotationTargetpublic final MethodInfo asMethod()
AnnotationTargetMethodInfo if it is of kind METHODasMethod in interface AnnotationTargetpublic final MethodParameterInfo asMethodParameter()
AnnotationTargetMethodParameterInfo if it is of kind METHOD_PARAMETERasMethodParameter in interface AnnotationTargetpublic final TypeTarget asType()
AnnotationTargetTypeTarget if it is of kind TYPEasType in interface AnnotationTargetpublic final RecordComponentInfo asRecordComponent()
AnnotationTargetRecordComponentInfo if it is of kind RECORD_COMPONENTasRecordComponent in interface AnnotationTargetpublic boolean hasAnnotation(DotName name)
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).
hasAnnotation in interface AnnotationTargetname - name of the annotation type to look for, must not be nulltrue if the annotation is present, false otherwiseannotation(DotName)public AnnotationInstance annotation(DotName name)
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).
annotation in interface AnnotationTargetname - name of the annotation type to look for, must not be nullnull if not foundannotations(DotName)public List<AnnotationInstance> annotations(DotName name)
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.
annotations in interface AnnotationTargetname - name of the annotation type, must not be nullnullannotationsWithRepeatable(DotName, IndexView),
annotations()public List<AnnotationInstance> annotationsWithRepeatable(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.
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).
annotationsWithRepeatable in interface AnnotationTargetname - 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()public List<AnnotationInstance> annotations()
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().
annotations in interface AnnotationTargetnullpublic boolean hasDeclaredAnnotation(DotName name)
hasDeclaredAnnotation in interface AnnotationTargetname - name of the annotation type to look for, must not be nulltrue if the annotation is present, false otherwisehasAnnotation(DotName)public AnnotationInstance declaredAnnotation(DotName name)
declaredAnnotation in interface AnnotationTargetname - name of the annotation type to look for, must not be nullnull if not foundannotation(DotName)public List<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.
declaredAnnotationsWithRepeatable in interface AnnotationTargetname - 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)public List<AnnotationInstance> declaredAnnotations()
declaredAnnotations in interface AnnotationTargetnullannotations()Copyright © 2018–2022. All rights reserved.