| com.sun.xml.bind.v2.model.annotation.AnnotationReader
AnnotationReader | public interface AnnotationReader (Code) | | Reads annotations for the given property.
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.
author: Kohsuke Kawaguchi (kk@kohsuke.org) |
Method Summary | |
Annotation[] | getAllFieldAnnotations(F field, Locatable srcPos) Gets all the annotations on a field. | Annotation[] | getAllMethodAnnotations(M method, Locatable srcPos) Gets all the annotations on a method. | A | getClassAnnotation(Class<A> annotation, C clazz, Locatable srcpos) Reads an annotation on a class. | T[] | getClassArrayValue(Annotation a, String name) Similar to
AnnotationReader.getClassValue(Annotation,String) method but
obtains an array parameter. | T | getClassValue(Annotation a, String name) Reads a value of an annotation that returns a Class object. | A | getFieldAnnotation(Class<A> annotation, F field, Locatable srcpos) Reads an annotation on a property that consists of a field. | 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. | A | getMethodAnnotation(Class<A> annotation, M method, Locatable srcpos) | A | getMethodParameterAnnotation(Class<A> annotation, M method, int paramIndex, Locatable srcPos) Reads an annotation on a parameter of the method. | A | getPackageAnnotation(Class<A> annotation, C clazz, Locatable srcpos) Reads an annotation on the package that the given class belongs to. | boolean | hasClassAnnotation(C clazz, Class<? extends Annotation> annotationType) Checks if a class has the annotation. | boolean | hasFieldAnnotation(Class<? extends Annotation> annotationType, F field) Checks if the given field has an annotation. | boolean | hasMethodAnnotation(Class<? extends Annotation> annotation, String propertyName, M getter, M setter, Locatable srcPos) Checks if the given method has an annotation. | boolean | hasMethodAnnotation(Class<? extends Annotation> annotation, M method) | void | setErrorHandler(ErrorHandler errorHandler) Sets the error handler that receives errors found
during reading annotations. |
getAllFieldAnnotations | Annotation[] getAllFieldAnnotations(F field, Locatable srcPos)(Code) | | Gets all the annotations on a field.
|
getAllMethodAnnotations | Annotation[] getAllMethodAnnotations(M method, Locatable srcPos)(Code) | | Gets all the annotations on a method.
Parameters: srcPos - the location from which this annotation is read. |
getClassAnnotation | A getClassAnnotation(Class<A> annotation, C clazz, Locatable srcpos)(Code) | | Reads an annotation on a class.
|
getClassValue | T getClassValue(Annotation a, String name)(Code) | | Reads a value of an annotation that returns a Class object.
Depending on the underlying reflection library, you can't always
obtain the
Class object directly (see the APT MirrorTypeException
for example), so use this method to avoid that.
Parameters: name - The name of the annotation parameter to be read. |
getFieldAnnotation | A getFieldAnnotation(Class<A> annotation, F field, Locatable srcpos)(Code) | | Reads an annotation on a property that consists of a field.
|
getMethodAnnotation | A getMethodAnnotation(Class<A> annotation, M getter, M setter, Locatable srcpos)(Code) | | Reads an annotation on a property that consists of a getter and a setter.
|
getMethodParameterAnnotation | A getMethodParameterAnnotation(Class<A> annotation, M method, int paramIndex, Locatable srcPos)(Code) | | Reads an annotation on a parameter of the method.
nullif the annotation was not found. |
getPackageAnnotation | A getPackageAnnotation(Class<A> annotation, C clazz, Locatable srcpos)(Code) | | Reads an annotation on the package that the given class belongs to.
|
hasClassAnnotation | boolean hasClassAnnotation(C clazz, Class<? extends Annotation> annotationType)(Code) | | Checks if a class has the annotation.
|
hasFieldAnnotation | boolean hasFieldAnnotation(Class<? extends Annotation> annotationType, F field)(Code) | | Checks if the given field has an annotation.
|
hasMethodAnnotation | boolean hasMethodAnnotation(Class<? extends Annotation> annotation, String propertyName, M getter, M setter, Locatable srcPos)(Code) | | Checks if the given method has an annotation.
|
setErrorHandler | void setErrorHandler(ErrorHandler errorHandler)(Code) | | Sets the error handler that receives errors found
during reading annotations.
Parameters: errorHandler - must not be null. |
|
|