|
The Spring Framework | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.springframework.core.annotation.AnnotationUtils
public abstract class AnnotationUtils
General utility methods for working with annotations, handling bridge methods (which the compiler generates for generic declarations) as well as super methods (for optional "annotation inheritance"). Note that none of this is provided by the JDK's introspection facilities themselves.
As a general rule for runtime-retained annotations (e.g. for transaction
control, authorization or service exposure), always use the lookup methods
on this class instead of the plain annotation lookup methods in the JDK.
You can still explicitly choose between lookup on the given class level only
(getAnnotation(java.lang.reflect.Method, java.lang.Class)
) and lookup in the entire inheritance hierarchy of
the given method (findAnnotation(java.lang.reflect.Method, java.lang.Class)
).
AccessibleObject.getAnnotations()
,
Method.getAnnotation(Class)
Constructor Summary | |
---|---|
AnnotationUtils()
|
Method Summary | ||
---|---|---|
static
|
findAnnotation(Method method,
Class<A> annotationType)
Get a single Annotation of annotationType from the
supplied Method , traversing its super methods if no annotation
can be found on the given method. |
|
static
|
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 |
---|
public AnnotationUtils()
Method Detail |
---|
public static Annotation[] getAnnotations(Method method)
Annotations
from the supplied Method
.
Correctly handles bridge Methods
generated by the compiler.
method
- the method to look for annotations on
BridgeMethodResolver.findBridgedMethod(Method)
public static <A extends Annotation> A getAnnotation(Method method, Class<A> annotationType)
Annotation
of annotationType
from the
supplied Method
.
Correctly handles bridge Methods
generated by the compiler.
method
- the method to look for annotations onannotationType
- the annotation class to look for
BridgeMethodResolver.findBridgedMethod(Method)
public static <A extends Annotation> A findAnnotation(Method method, Class<A> annotationType)
Annotation
of annotationType
from the
supplied Method
, traversing its super methods if no annotation
can be found on the given method.
Annotations on methods are not inherited by default, so we need to handle this explicitly.
method
- the method to look for annotations onannotationType
- the annotation class to look for
null
|
The Spring Framework | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |