Interface AnnotatedType
4.2 Primitive Types and Values
4.3 Reference Types and Values
4.4 Type Variables
4.5 Parameterized Types
4.8 Raw Types
4.9 Intersection Types
10.1 Array Types
Since: 1.8
-
Method Summary
All MethodsInstance MethodsAbstract MethodsDefault MethodsModifier and TypeMethodDescriptiondefault AnnotatedTypeReturns the potentially annotated type that this type is a member of, if this type represents a nested type.<T extends Annotation>
TgetAnnotation(Class<T> annotationClass)Returns this element's annotation for the specified type if such an annotation is present, else null.Returns annotations that are present on this element.Returns annotations that are directly present on this element.getType()Returns the underlying type that this annotated type represents.Methods declared in interface AnnotatedElement
getAnnotationsByType, getDeclaredAnnotation, getDeclaredAnnotationsByType, isAnnotationPresentModifier and TypeMethodDescriptiondefault <T extends Annotation>
T[]getAnnotationsByType(Class<T> annotationClass)Returns annotations that are associated with this element.default <T extends Annotation>
TgetDeclaredAnnotation(Class<T> annotationClass)Returns this element's annotation for the specified type if such an annotation is directly present, else null.default <T extends Annotation>
T[]getDeclaredAnnotationsByType(Class<T> annotationClass)Returns this element's annotation(s) for the specified type if such annotations are either directly present or indirectly present.default booleanReturns true if an annotation for the specified type is present on this element, else false.
-
Method Details
-
getAnnotatedOwnerType
Returns the potentially annotated type that this type is a member of, if this type represents a nested type. For example, if this type is @TA O<T>.I<S>, return a representation of @TA O<T>.Implementation Requirements: This default implementation returns null and performs no other action. Returns: an AnnotatedType object representing the potentially annotated type that this type is a member of, or null 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: 9Returns 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.
-
getType
Type getType()Returns the underlying type that this annotated type represents.Returns: the type this annotated type represents -
getAnnotation
Returns this element's annotation for the specified type if such an annotation is present, else null.Specified by: getAnnotation in interface AnnotatedElement 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 nullNote that any annotation returned by this method is a type annotation.
-
getAnnotations
Annotation[] getAnnotations()Returns annotations that are present on this element. If there are no annotations present on this element, the return value is an array of length 0. The caller of this method is free to modify the returned array; it will have no effect on the arrays returned to other callers.Specified by: getAnnotations in interface AnnotatedElement Returns: annotations present on this elementNote that any annotations returned by this method are type annotations.
-
getDeclaredAnnotations
Annotation[] getDeclaredAnnotations()Returns annotations that are directly present on this element. This method ignores inherited annotations. If there are no annotations directly present on this element, the return value is an array of length 0. The caller of this method is free to modify the returned array; it will have no effect on the arrays returned to other callers.Specified by: getDeclaredAnnotations in interface AnnotatedElement Returns: annotations directly present on this elementNote that any annotations returned by this method are type annotations.
-
Report a bug or suggest an enhancement
For further API reference and developer documentation see the Java SE Documentation, which contains more detailed, developer-targeted descriptions with conceptual overviews, definitions of terms, workarounds, and working code examples. Other versions.
Java is a trademark or registered trademark of Oracle and/or its affiliates in the US and other countries.
Copyright © 1993, 2026, Oracle and/or its affiliates, 500 Oracle Parkway, Redwood Shores, CA 94065 USA.
All rights reserved. Use is subject to license terms and the documentation redistribution policy.