public class AnnotationParser
extends java.lang.Object
There are 3 ways how this class can be used. First, it can be used on single annotation, but that does not make much sense.
Second way is with child and parent annotation. The parent annotation is default one, like a base class. Child annotation contains some predefined values different from parent. Note that child annotation does NOT have to specify all elements - all missing elements will be read from default parent annotation. So child annotation behaves like it is overriding the parent one.
Third way is similar, except the child annotation is also annotated with parent annotation! Besides overriding features and default values, this way we can finalize some element value and prevent it from being modified by user.
Modifier and Type | Class and Description |
---|---|
class |
AnnotationParser.Reader |
Modifier and Type | Field and Description |
---|---|
protected java.lang.Class<? extends java.lang.annotation.Annotation> |
annotationClass |
protected java.lang.annotation.Annotation |
defaultAnnotation |
Constructor and Description |
---|
AnnotationParser(java.lang.Class<? extends java.lang.annotation.Annotation> annotationClass) |
AnnotationParser(java.lang.Class<? extends java.lang.annotation.Annotation> annotationClass,
java.lang.Class<? extends java.lang.annotation.Annotation> defaultAnnotationClass)
Creates new annotation data reader using annotation definition
from class generics.
|
Modifier and Type | Method and Description |
---|---|
java.lang.Class<? extends java.lang.annotation.Annotation> |
getAnnotationType()
Returns annotation type of this parser.
|
boolean |
hasAnnotationOn(java.lang.reflect.AnnotatedElement annotatedElement)
Returns
true if annotation is present on
given annotated element. |
AnnotationParser.Reader |
of(java.lang.reflect.AnnotatedElement annotatedElement)
Returns an annotation reader of annotated element.
|
protected final java.lang.annotation.Annotation defaultAnnotation
protected final java.lang.Class<? extends java.lang.annotation.Annotation> annotationClass
public AnnotationParser(java.lang.Class<? extends java.lang.annotation.Annotation> annotationClass)
public AnnotationParser(java.lang.Class<? extends java.lang.annotation.Annotation> annotationClass, java.lang.Class<? extends java.lang.annotation.Annotation> defaultAnnotationClass)
annotationClass
- annotation type to read fromdefaultAnnotationClass
- optional default annotation type, used to annotate the annotation class.public java.lang.Class<? extends java.lang.annotation.Annotation> getAnnotationType()
public boolean hasAnnotationOn(java.lang.reflect.AnnotatedElement annotatedElement)
true
if annotation is present on
given annotated element. Should be called first, before using the read methods.public AnnotationParser.Reader of(java.lang.reflect.AnnotatedElement annotatedElement)
Copyright © 2003-present Jodd Team