Interface Annotated
-
- All Known Subinterfaces:
AnnotatedCallable<X>
,AnnotatedConstructor<X>
,AnnotatedField<X>
,AnnotatedMember<X>
,AnnotatedMethod<X>
,AnnotatedParameter<X>
,AnnotatedType<X>
,EnhancedAnnotated<T,S>
,EnhancedAnnotatedCallable<T,X,S>
,EnhancedAnnotatedConstructor<T>
,EnhancedAnnotatedField<T,X>
,EnhancedAnnotatedMember<T,X,S>
,EnhancedAnnotatedMethod<T,X>
,EnhancedAnnotatedParameter<T,X>
,EnhancedAnnotatedType<T>
,EnhancedAnnotation<T>
,SlimAnnotatedType<T>
- All Known Implementing Classes:
AbstractEnhancedAnnotated
,AbstractEnhancedAnnotatedCallable
,AbstractEnhancedAnnotatedMember
,AnnotatedTypeWrapper
,BackedAnnotated
,BackedAnnotatedCallable
,BackedAnnotatedConstructor
,BackedAnnotatedField
,BackedAnnotatedMember
,BackedAnnotatedMethod
,BackedAnnotatedParameter
,BackedAnnotatedType
,BaseAnnotated
,EmptyAnnotated
,EnhancedAnnotatedConstructorImpl
,EnhancedAnnotatedFieldImpl
,EnhancedAnnotatedMethodImpl
,EnhancedAnnotatedParameterImpl
,EnhancedAnnotatedTypeImpl
,EnhancedAnnotationImpl
,ForwardingAnnotated
,ForwardingAnnotatedCallable
,ForwardingAnnotatedConstructor
,ForwardingAnnotatedField
,ForwardingAnnotatedMember
,ForwardingAnnotatedMethod
,ForwardingAnnotatedParameter
,ForwardingAnnotatedType
,InvokableAnnotatedMethod
,UnbackedAnnotated
,UnbackedAnnotatedConstructor
,UnbackedAnnotatedField
,UnbackedAnnotatedMember
,UnbackedAnnotatedMethod
,UnbackedAnnotatedParameter
,UnbackedAnnotatedType
,VetoedSuppressedAnnotatedType
public interface Annotated
Represents a Java program element that can be annotated.
- Author:
- Gavin King, Pete Muir, Clint Popetz, John D. Ament
- See Also:
AnnotatedElement
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description <T extends Annotation>
TgetAnnotation(Class<T> annotationType)
Get program element annotation of a certain annotation type.Set<Annotation>
getAnnotations()
Get all annotations of the program element.<T extends Annotation>
Set<T>getAnnotations(Class<T> annotationType)
Get program element annotations of a certain annotation type.Type
getBaseType()
Get the type of the annotated program element.Set<Type>
getTypeClosure()
Get all types to which the base type should be considered assignable.boolean
isAnnotationPresent(Class<? extends Annotation> annotationType)
Determine if the program element has an annotation of a certain annotation type.
-
-
-
Method Detail
-
getBaseType
Type getBaseType()
Get the type of the annotated program element.
- Returns:
- the type of the annotated program element
-
getTypeClosure
Set<Type> getTypeClosure()
Get all types to which the base type should be considered assignable.
- Returns:
- a set of all types to which the base type should be considered assignable
-
getAnnotation
<T extends Annotation> T getAnnotation(Class<T> annotationType)
Get program element annotation of a certain annotation type. The behavior of this method is intended to be the same behavior as
AnnotatedElement.getAnnotation(Class)
, where repeatable annotations are not supported.- Type Parameters:
T
- the type of the annotation- Parameters:
annotationType
- the class of the annotation type- Returns:
- the first program element annotation of the given annotation type, or a null value
-
getAnnotations
<T extends Annotation> Set<T> getAnnotations(Class<T> annotationType)
Get program element annotations of a certain annotation type.
This method returns back all annotations, including repeatable annotations of this type. The behavior of this method is intended to be the same behavior as
AnnotatedElement.getAnnotationsByType(Class)
, where repeatable annotations are supported.- Type Parameters:
T
- the type of the annotation- Parameters:
annotationType
- the class of the annotation type- Returns:
- the program element annotations of the given annotation type, or an empty collection
-
getAnnotations
Set<Annotation> getAnnotations()
Get all annotations of the program element.
- Returns:
- all annotations of the program element, or an empty set if no annotations are present
-
isAnnotationPresent
boolean isAnnotationPresent(Class<? extends Annotation> annotationType)
Determine if the program element has an annotation of a certain annotation type. The behavior of this method is similar to
AnnotatedElement.isAnnotationPresent(Class)
for the underlying program element.- Parameters:
annotationType
- the annotation type to check for- Returns:
true
if the program element has an annotation of the given annotation type, orfalse
otherwise
-
-