public abstract class AnnoConstruct extends Object implements AnnotatedConstruct
This is NOT part of any supported API. If you write code that depends on this, you do so at your own risk. This code and its internal interfaces are subject to change or deletion without notice.
Constructor and Description |
---|
AnnoConstruct() |
Modifier and Type | Method and Description |
---|---|
<A extends Annotation> |
getAnnotation(Class<A> annoType)
Returns this construct's annotation of the specified type if
such an annotation is present, else
null . |
abstract List<? extends Attribute.Compound> |
getAnnotationMirrors()
Returns the annotations that are directly present on
this construct.
|
<A extends Annotation> |
getAnnotationsByType(Class<A> annoType)
Returns annotations that are associated with this construct.
|
protected <A extends Annotation> |
getAttribute(Class<A> annoType) |
protected <A extends Annotation> |
getInheritedAnnotations(Class<A> annoType) |
public abstract List<? extends Attribute.Compound> getAnnotationMirrors()
AnnotatedConstruct
getAnnotationMirrors
in interface AnnotatedConstruct
protected <A extends Annotation> Attribute.Compound getAttribute(Class<A> annoType)
protected <A extends Annotation> A[] getInheritedAnnotations(Class<A> annoType)
public <A extends Annotation> A[] getAnnotationsByType(Class<A> annoType)
AnnotatedConstruct
AnnotatedConstruct.getAnnotation(Class)
is that this method detects if its argument is a repeatable
annotation type, and if so, attempts to find one or more
annotations of that type by "looking through" a container annotation.
The annotations returned by this method could contain an element
whose value is of type Class
.
This value cannot be returned directly: information necessary to
locate and load a class (such as the class loader to use) is
not available, and the class might not be loadable at all.
Attempting to read a Class
object by invoking the relevant
method on the returned annotation
will result in a MirroredTypeException
,
from which the corresponding TypeMirror
may be extracted.
Similarly, attempting to read a Class[]
-valued element
will result in a MirroredTypesException
.
Note: This method is unlike others in this and related interfaces. It operates on runtime reflective information — representations of annotation types currently loaded into the VM — rather than on the representations defined by and used throughout these interfaces. Consequently, calling methods on the returned annotation object can throw many of the exceptions that can be thrown when calling methods on an annotation object returned by core reflection. This method is intended for callers that are written to operate on a known, fixed set of annotation types.
getAnnotationsByType
in interface AnnotatedConstruct
A
- the annotation typeannoType
- the Class
object corresponding to
the annotation typeAnnotatedConstruct.getAnnotationMirrors()
,
AnnotatedConstruct.getAnnotation(Class)
,
AnnotatedElement.getAnnotationsByType(Class)
,
EnumConstantNotPresentException
,
AnnotationTypeMismatchException
,
IncompleteAnnotationException
,
MirroredTypeException
,
MirroredTypesException
public <A extends Annotation> A getAnnotation(Class<A> annoType)
AnnotatedConstruct
null
.
The annotation returned by this method could contain an element
whose value is of type Class
.
This value cannot be returned directly: information necessary to
locate and load a class (such as the class loader to use) is
not available, and the class might not be loadable at all.
Attempting to read a Class
object by invoking the relevant
method on the returned annotation
will result in a MirroredTypeException
,
from which the corresponding TypeMirror
may be extracted.
Similarly, attempting to read a Class[]
-valued element
will result in a MirroredTypesException
.
Note: This method is unlike others in this and related interfaces. It operates on runtime reflective information — representations of annotation types currently loaded into the VM — rather than on the representations defined by and used throughout these interfaces. Consequently, calling methods on the returned annotation object can throw many of the exceptions that can be thrown when calling methods on an annotation object returned by core reflection. This method is intended for callers that are written to operate on a known, fixed set of annotation types.
getAnnotation
in interface AnnotatedConstruct
A
- the annotation typeannoType
- the Class
object corresponding to
the annotation typenull
AnnotatedConstruct.getAnnotationMirrors()
,
AnnotatedElement.getAnnotation(java.lang.Class<T>)
,
EnumConstantNotPresentException
,
AnnotationTypeMismatchException
,
IncompleteAnnotationException
,
MirroredTypeException
,
MirroredTypesException
Copyright © 2015. All rights reserved.