AnnotatedElement
AnnotatedArrayType
, AnnotatedParameterizedType
, AnnotatedTypeVariable
, AnnotatedWildcardType
public interface AnnotatedType extends AnnotatedElement
AnnotatedType
represents the potentially annotated use of a type in the program currently running in this VM. The use may be of any type in the Java programming language, including an array type, a parameterized type, a type variable, or a wildcard type. Note that any annotations returned by methods on this interface are type annotations (JLS 9.7.4) as the entity being potentially annotated is a type.Modifier and Type | Method | Description |
---|---|---|
default AnnotatedType |
getAnnotatedOwnerType() |
Returns the potentially annotated type that this type is a member of, if this type represents a nested type. |
<T extends Annotation> |
getAnnotation |
Returns this element's annotation for the specified type if such an annotation is present, else null. |
Annotation[] |
getAnnotations() |
Returns annotations that are present on this element. |
Annotation[] |
getDeclaredAnnotations() |
Returns annotations that are directly present on this element. |
Type |
getType() |
Returns the underlying type that this annotated type represents. |
getAnnotationsByType, getDeclaredAnnotation, getDeclaredAnnotationsByType, isAnnotationPresent
default AnnotatedType getAnnotatedOwnerType()
@TA O<T>.I<S>
, return a representation of @TA O<T>
. Returns null
if this AnnotatedType
represents a top-level class or interface, or a local or anonymous class, or a primitive type, or void.
Returns null
if this AnnotatedType
is an instance of AnnotatedArrayType
, AnnotatedTypeVariable
, or AnnotatedWildcardType
.
null
and performs no other action.AnnotatedType
object representing the potentially annotated type that this type is a member of, or null
TypeNotPresentException
- if the owner type refers to a non-existent class or interface declarationMalformedParameterizedTypeException
- if the owner type refers to a parameterized type that cannot be instantiated for any reasonType getType()
<T extends Annotation> T getAnnotation(Class<T> annotationClass)
Note that any annotation returned by this method is a type annotation.
getAnnotation
in interface AnnotatedElement
T
- the type of the annotation to query for and return if presentannotationClass
- the Class object corresponding to the annotation typeNullPointerException
- if the given annotation class is nullAnnotation[] getAnnotations()
Note that any annotations returned by this method are type annotations.
getAnnotations
in interface AnnotatedElement
Annotation[] getDeclaredAnnotations()
Note that any annotations returned by this method are type annotations.
getDeclaredAnnotations
in interface AnnotatedElement
© 1993, 2023, Oracle and/or its affiliates. All rights reserved.
Documentation extracted from Debian's OpenJDK Development Kit package.
Licensed under the GNU General Public License, version 2, with the Classpath Exception.
Various third party code in OpenJDK is licensed under different licenses (see Debian package).
Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
https://docs.oracle.com/en/java/javase/21/docs/api/java.base/java/lang/reflect/AnnotatedType.html