This is the lowest abstraction that encapsulates the difference between reading inline annotations and external binding files.
Because the former operates on a Field and Method
while the latter operates on a "property", the methods defined
on this interface takes both, and the callee gets to choose which
to use.
Most of the get method takes Locatable, which points to
the place/context in which the annotation is read. The returned
annotation also implements Locatable (so that it can
point to the place where the annotation is placed), and its
Locatable#getUpstream() will return the given
Locatable.
Errors found during reading annotations are reported through the error handler.
A valid ErrorHandler must be registered before the AnnotationReader
is used.
| Modifier and Type | Method and Description |
|---|---|
| public Annotation[] | |
| public Annotation[] | getAllMethodAnnotations(M method, Locatable
the location from which this annotation is read. srcPos)Gets all the annotations on a method. |
| public <A extends Annotation> A | |
| public T[] | getClassArrayValue(Annotation a, String name)
Similar to |
| public T | getClassValue(Annotation a, String
The name of the annotation parameter to be read. name)Reads a value of an annotation that returns a Class object. |
| public <A extends Annotation> A | getFieldAnnotation(Class<A> annotation, F field, Locatable srcpos)
Reads an annotation on a property that consists of a field. |
| public <A extends Annotation> A | getMethodAnnotation(Class<A> annotation, M getter, M setter, Locatable srcpos)
Reads an annotation on a property that consists of a getter and a setter. |
| public <A extends Annotation> A | |
| public <A extends Annotation> A | Returns: null if the annotation was not found.Reads an annotation on a parameter of the method. |
| public <A extends Annotation> A | getPackageAnnotation(Class<A> annotation, C clazz, Locatable srcpos)
Reads an annotation on the package that the given class belongs to. |
| public boolean | hasClassAnnotation(C clazz, Class<? extends Annotation> annotationType)
Checks if a class has the annotation. |
| public boolean | hasFieldAnnotation(Class<? extends Annotation> annotationType, F field)
Checks if the given field has an annotation. |
| public boolean | hasMethodAnnotation(Class<? extends Annotation> annotation, String propertyName, M getter, M setter, Locatable srcPos)
Checks if the given method has an annotation. |
| public boolean | |
| public void | setErrorHandler(ErrorHandler
must not be null. errorHandler)Sets the error handler that receives errors found during reading annotations. |
| getAllFieldAnnotations | back to summary |
|---|---|
| public Annotation[] getAllFieldAnnotations(F field, Locatable srcPos) Gets all the annotations on a field. | |
| getAllMethodAnnotations | back to summary |
|---|---|
| public Annotation[] getAllMethodAnnotations(M method, Locatable srcPos) Gets all the annotations on a method.
| |
| getClassAnnotation | back to summary |
|---|---|
| public <A extends Annotation> A getClassAnnotation(Class<A> annotation, C clazz, Locatable srcpos) Reads an annotation on a class.
| |
| getClassArrayValue | back to summary |
|---|---|
| public T[] getClassArrayValue(Annotation a, String name) Similar to | |
| getClassValue | back to summary |
|---|---|
| public T getClassValue(Annotation a, String name) Reads a value of an annotation that returns a Class object.
Depending on the underlying reflection library, you can't always
obtain the
| |
| getFieldAnnotation | back to summary |
|---|---|
| public <A extends Annotation> A getFieldAnnotation(Class<A> annotation, F field, Locatable srcpos) Reads an annotation on a property that consists of a field. | |
| getMethodAnnotation | back to summary |
|---|---|
| public <A extends Annotation> A getMethodAnnotation(Class<A> annotation, M getter, M setter, Locatable srcpos) Reads an annotation on a property that consists of a getter and a setter. | |
| getMethodAnnotation | back to summary |
|---|---|
| public <A extends Annotation> A getMethodAnnotation(Class<A> annotation, M method, Locatable srcpos) | |
| getMethodParameterAnnotation | back to summary |
|---|---|
| public <A extends Annotation> A getMethodParameterAnnotation(Class<A> annotation, M method, int paramIndex, Locatable srcPos) Reads an annotation on a parameter of the method.
| |
| getPackageAnnotation | back to summary |
|---|---|
| public <A extends Annotation> A getPackageAnnotation(Class<A> annotation, C clazz, Locatable srcpos) Reads an annotation on the package that the given class belongs to.
| |
| hasClassAnnotation | back to summary |
|---|---|
| public boolean hasClassAnnotation(C clazz, Class<? extends Annotation> annotationType) Checks if a class has the annotation. | |
| hasFieldAnnotation | back to summary |
|---|---|
| public boolean hasFieldAnnotation(Class<? extends Annotation> annotationType, F field) Checks if the given field has an annotation. | |
| hasMethodAnnotation | back to summary |
|---|---|
| public boolean hasMethodAnnotation(Class<? extends Annotation> annotation, String propertyName, M getter, M setter, Locatable srcPos) Checks if the given method has an annotation. | |
| hasMethodAnnotation | back to summary |
|---|---|
| public boolean hasMethodAnnotation(Class<? extends Annotation> annotation, M method) | |
| setErrorHandler | back to summary |
|---|---|
| public void setErrorHandler(ErrorHandler errorHandler) Sets the error handler that receives errors found during reading annotations.
| |