net.sf.jsefa.common.annotation
Class AnnotationDataProvider

java.lang.Object
  extended by net.sf.jsefa.common.annotation.AnnotationDataProvider

public final class AnnotationDataProvider
extends Object

Provider for values of annotation parameters. It provides a simple solution to the following drawbacks of annotations:
1) Annotations can not extend an interface so that it is not possible to express that several annotations do provide the same kind of data.
2) Annotated parameter values can not be set to null.

Author:
Norman Lahme-Huetig

Method Summary
static
<T> T
get(AnnotatedElement annotatedElement, String annotationParameterName, Class<? extends Annotation>... annotationClasses)
          Returns the value of the annotation parameter with the given name of the annotation the given annotatedElement is annotated with and which class is one of the given annotation classes.
static
<T> T
get(Annotation annotation, String annotationParameterName)
          Returns the value of the annotation parameter with the given name of the given annotation or null if it is to be interpreted as null (as the empty String, an empty array or special classes used as defaults for the annotation parameter value).
static boolean hasParameter(Class<? extends Annotation> annotationClass, String annotationParameterName)
          Returns true if the annotation class has an annotation parameter with the given name; false otherwise.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

get

public static <T> T get(Annotation annotation,
                        String annotationParameterName)
Returns the value of the annotation parameter with the given name of the given annotation or null if it is to be interpreted as null (as the empty String, an empty array or special classes used as defaults for the annotation parameter value).

Type Parameters:
T - the expected type of the data to return
Parameters:
annotation - the annotation
annotationParameterName - the annotation parameter name
Returns:
the annotation parameter value.

get

public static <T> T get(AnnotatedElement annotatedElement,
                        String annotationParameterName,
                        Class<? extends Annotation>... annotationClasses)
Returns the value of the annotation parameter with the given name of the annotation the given annotatedElement is annotated with and which class is one of the given annotation classes. Returns null, if the annotation parameter value is to be interpreted as null (as the empty String or special classes used as defaults for the annotation parameter value).

Type Parameters:
T - the expected type of the returned data
Parameters:
annotatedElement - the annotated element
annotationParameterName - the name of the annotation parameter
annotationClasses - the annotation classes
Returns:
the annotation parameter value

hasParameter

public static boolean hasParameter(Class<? extends Annotation> annotationClass,
                                   String annotationParameterName)
Returns true if the annotation class has an annotation parameter with the given name; false otherwise.

Parameters:
annotationClass - the annotation class
annotationParameterName - the annotation parameter name
Returns:
true if the annotation class has an annotation parameter with the given name; false otherwise.


Copyright © 2014. All rights reserved.