jodd.util
Class AnnotationDataReader<A extends java.lang.annotation.Annotation,D extends AnnotationDataReader.AnnotationData<A>>

java.lang.Object
  extended by jodd.util.AnnotationDataReader<A,D>

public abstract class AnnotationDataReader<A extends java.lang.annotation.Annotation,D extends AnnotationDataReader.AnnotationData<A>>
extends java.lang.Object

Annotation reader that reads an annotation and returns annotation data object filled with annotation element values. May be used when having two or more annotations with same elements - since java doesn't support annotation inheritance.


Nested Class Summary
static class AnnotationDataReader.AnnotationData<N extends java.lang.annotation.Annotation>
          Base class for annotation data, for holding annotation elements values.
 
Field Summary
protected  java.lang.Class<A> annotationClass
           
 
Constructor Summary
protected AnnotationDataReader()
          Creates new annotation data reader using annotation definition from class generics.
protected AnnotationDataReader(java.lang.Class<A> annotationClass)
          Creates new annotation data reader using provided annotation class.
 
Method Summary
protected abstract  D createAnnotationData(A annotation)
          Creates annotation data from given annotation.
 java.lang.Class<A> getAnnotationClass()
          Returns annotation class.
 boolean hasAnnotation(java.lang.reflect.AccessibleObject accessibleObject)
          Returns true if annotation is present on given accessible object.
 D readAnnotationData(java.lang.reflect.AccessibleObject accessibleObject)
          Reads annotation data on provided accessible object.
protected  java.lang.Object readElement(A annotation, java.lang.String name)
          Reads annotation element as an object.
protected  java.lang.String readStringElement(A annotation, java.lang.String name)
          Reads non-empty, trimmed, annotation element value.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

annotationClass

protected final java.lang.Class<A extends java.lang.annotation.Annotation> annotationClass
Constructor Detail

AnnotationDataReader

protected AnnotationDataReader()
Creates new annotation data reader using annotation definition from class generics.


AnnotationDataReader

protected AnnotationDataReader(java.lang.Class<A> annotationClass)
Creates new annotation data reader using provided annotation class.

Method Detail

getAnnotationClass

public java.lang.Class<A> getAnnotationClass()
Returns annotation class.


hasAnnotation

public boolean hasAnnotation(java.lang.reflect.AccessibleObject accessibleObject)
Returns true if annotation is present on given accessible object.


readAnnotationData

public D readAnnotationData(java.lang.reflect.AccessibleObject accessibleObject)
Reads annotation data on provided accessible object. If annotation is not presented, null is returned.


createAnnotationData

protected abstract D createAnnotationData(A annotation)
Creates annotation data from given annotation.


readStringElement

protected java.lang.String readStringElement(A annotation,
                                             java.lang.String name)
Reads non-empty, trimmed, annotation element value. If annotation value is an empty string, returns null.


readElement

protected java.lang.Object readElement(A annotation,
                                       java.lang.String name)
Reads annotation element as an object.



Copyright © 2003-2012 Jodd Team