Interface AnnotatedType
- All Superinterfaces:
AnnotatedElement
- All Known Subinterfaces:
-
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.Method Summary
| 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. |
Methods declared in interface java.lang.reflect.AnnotatedElement
getAnnotationsByType, getDeclaredAnnotation, getDeclaredAnnotationsByType, isAnnotationPresent
Method Details
getAnnotatedOwnerType
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.
- Implementation Requirements:
- This default implementation returns
nulland performs no other action. - Returns:
- an
AnnotatedTypeobject representing the potentially annotated type that this type is a member of, ornull - Throws:
-
TypeNotPresentException- if the owner type refers to a non-existent class or interface declaration -
MalformedParameterizedTypeException- if the owner type refers to a parameterized type that cannot be instantiated for any reason - Since:
- 9
getType
Type getType()
- Returns:
- the type this annotated type represents
getAnnotation
<T extends Annotation> T getAnnotation(Class<T> annotationClass)
Note that any annotation returned by this method is a type annotation.
- Specified by:
-
getAnnotationin interfaceAnnotatedElement - Type Parameters:
-
T- the type of the annotation to query for and return if present - Parameters:
-
annotationClass- the Class object corresponding to the annotation type - Returns:
- this element's annotation for the specified annotation type if present on this element, else null
- Throws:
-
NullPointerException- if the given annotation class is null
getAnnotations
Annotation[] getAnnotations()
Note that any annotations returned by this method are type annotations.
- Specified by:
-
getAnnotationsin interfaceAnnotatedElement - Returns:
- annotations present on this element
getDeclaredAnnotations
Annotation[] getDeclaredAnnotations()
Note that any annotations returned by this method are type annotations.
- Specified by:
-
getDeclaredAnnotationsin interfaceAnnotatedElement - Returns:
- annotations directly present on this element
© 1993, 2021, 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/17/docs/api/java.base/java/lang/reflect/AnnotatedType.html