The Spring Framework

org.springframework.core.annotation
Class AnnotationUtils

java.lang.Object
  extended by org.springframework.core.annotation.AnnotationUtils

public abstract class AnnotationUtils
extends Object

General utility methods for working with annotations.

Since:
2.0
Author:
Rod Johnson, Rob Harrop, Juergen Hoeller

Constructor Summary
AnnotationUtils()
           
 
Method Summary
static
<A extends Annotation>
A
findAnnotation(Method method, Class<A> annotationType)
          Get a single Annotation of annotationType from the supplied Method.
static
<A extends Annotation>
A
getAnnotation(Method method, Class<A> annotationType)
          Get a single Annotation of annotationType from the supplied Method.
static Annotation[] getAnnotations(Method method)
          Get all Annotations from the supplied Method.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AnnotationUtils

public AnnotationUtils()
Method Detail

getAnnotations

public static Annotation[] getAnnotations(Method method)
Get all Annotations from the supplied Method.

Correctly handles bridge Methods generated by the compiler.

Parameters:
method - the method to look for annotations on
See Also:
BridgeMethodResolver.findBridgedMethod(Method)

getAnnotation

public static <A extends Annotation> A getAnnotation(Method method,
                                                     Class<A> annotationType)
Get a single Annotation of annotationType from the supplied Method.

Correctly handles bridge Methods generated by the compiler.

Parameters:
method - the method to look for annotations on
annotationType - the annotation class to look for
See Also:
BridgeMethodResolver.findBridgedMethod(Method)

findAnnotation

public static <A extends Annotation> A findAnnotation(Method method,
                                                      Class<A> annotationType)
Get a single Annotation of annotationType from the supplied Method.

Annotations on methods are not inherited by default, so we need to handle this explicitly.

Parameters:
method - the method to look for annotations on
annotationType - the annotation class to look for
Returns:
the annotation of the given type found, or null

The Spring Framework

Copyright © 2002-2006 The Spring Framework.