org.codehaus.backport175.reader
Class Annotations

java.lang.Object
  extended by org.codehaus.backport175.reader.Annotations

public final class Annotations
extends java.lang.Object

Helper class for reader retrieval of strongly typed JavaDoc annotations (as well as regular Java 5 java.lang.reader.RetentionPolicy.RUNTIME annotations when running Java 1.5.x).

Author:
Jonas Bonér

Constructor Summary
Annotations()
           
 
Method Summary
static Annotation getAnnotation(java.lang.Class annotationType, java.lang.Class target)
          Return the annotation with a specific name for a specific class.
static Annotation getAnnotation(java.lang.Class annotationType, java.lang.reflect.Constructor constructor)
          Return the annotation with a specific name for a specific constructor.
static Annotation getAnnotation(java.lang.Class annotationType, java.lang.reflect.Field field)
          Return the annotation with a specific name for a specific field.
static Annotation getAnnotation(java.lang.Class annotationType, java.lang.reflect.Method method)
          Return the annotation with a specific name for a specific method.
static Annotation[] getAnnotations(java.lang.Class target)
          Return all the annotations for a specific class.
static Annotation[] getAnnotations(java.lang.reflect.Constructor constructor)
          Return all the annotations for a specific constructor.
static Annotation[] getAnnotations(java.lang.reflect.Field field)
          Return all the annotations for a specific field.
static Annotation[] getAnnotations(java.lang.reflect.Method method)
          Return all the annotations for a specific method.
static boolean isAnnotationPresent(java.lang.Class annotationType, java.lang.Class target)
          Checks if an annotation is present at a specific class.
static boolean isAnnotationPresent(java.lang.Class annotationType, java.lang.reflect.Constructor constructor)
          Checks if an annotation is present at a specific method.
static boolean isAnnotationPresent(java.lang.Class annotationType, java.lang.reflect.Field field)
          Checks if an annotation is present at a specific field.
static boolean isAnnotationPresent(java.lang.Class annotationType, java.lang.reflect.Method method)
          Checks if an annotation is present at a specific method.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Annotations

public Annotations()
Method Detail

isAnnotationPresent

public static boolean isAnnotationPresent(java.lang.Class annotationType,
                                          java.lang.Class target)
Checks if an annotation is present at a specific class.

Parameters:
annotationType - the annotation type
target - the annotated type
Returns:
true if the annotation is present else false

getAnnotations

public static Annotation[] getAnnotations(java.lang.Class target)
Return all the annotations for a specific class.

Parameters:
target - the java.lang.Class object to find the annotations on.
Returns:
an array with the annotations

getAnnotation

public static Annotation getAnnotation(java.lang.Class annotationType,
                                       java.lang.Class target)
Return the annotation with a specific name for a specific class.

Parameters:
annotationType - the annotation class
target - the java.lang.Class object to find the annotation on.
Returns:
the annotation or null

isAnnotationPresent

public static boolean isAnnotationPresent(java.lang.Class annotationType,
                                          java.lang.reflect.Method method)
Checks if an annotation is present at a specific method.

Parameters:
annotationType - the annotation type
method - the annotated type
Returns:
true if the annotation is present else false

getAnnotations

public static Annotation[] getAnnotations(java.lang.reflect.Method method)
Return all the annotations for a specific method.

Parameters:
method - the java.lang.reflect.Method object to find the annotations on.
Returns:
an array with the annotations

getAnnotation

public static Annotation getAnnotation(java.lang.Class annotationType,
                                       java.lang.reflect.Method method)
Return the annotation with a specific name for a specific method.

Parameters:
annotationType - the annotation class
method - the java.lang.refect.Method object to find the annotation on.
Returns:
the annotation or null

isAnnotationPresent

public static boolean isAnnotationPresent(java.lang.Class annotationType,
                                          java.lang.reflect.Constructor constructor)
Checks if an annotation is present at a specific method.

Parameters:
annotationType - the annotation type
constructor - the annotated type
Returns:
true if the annotation is present else false

getAnnotations

public static Annotation[] getAnnotations(java.lang.reflect.Constructor constructor)
Return all the annotations for a specific constructor.

Parameters:
constructor - the java.lang.reflect.Constructor object to find the annotations on.
Returns:
an array with the annotations

getAnnotation

public static Annotation getAnnotation(java.lang.Class annotationType,
                                       java.lang.reflect.Constructor constructor)
Return the annotation with a specific name for a specific constructor.

Parameters:
annotationType - the annotation class
constructor - the java.lang.refect.Constructor object to find the annotation on.
Returns:
the annotation or null

isAnnotationPresent

public static boolean isAnnotationPresent(java.lang.Class annotationType,
                                          java.lang.reflect.Field field)
Checks if an annotation is present at a specific field.

Parameters:
annotationType - the annotation type
field - the annotated type
Returns:
true if the annotation is present else false

getAnnotations

public static Annotation[] getAnnotations(java.lang.reflect.Field field)
Return all the annotations for a specific field.

Parameters:
field - the java.lang.reflect.Field object to find the annotations on.
Returns:
an array with the annotations

getAnnotation

public static Annotation getAnnotation(java.lang.Class annotationType,
                                       java.lang.reflect.Field field)
Return the annotation with a specific name for a specific field.

Parameters:
annotationType - the annotation class
field - the java.lang.reflect.Field object to find the annotation on.
Returns:
the annotation or null