org.jboss.seam.solder.reflection
Class AnnotationInspector

java.lang.Object
  extended by org.jboss.seam.solder.reflection.AnnotationInspector

public class AnnotationInspector
extends Object

Inspect an AnnotatedElement or Annotated to obtain it's meta annotations and annotations, taking into account stereotypes.

Author:
Pete Muir

Method Summary
static
<A extends Annotation>
A
getAnnotation(AnnotatedElement element, Class<A> annotationType, boolean metaAnnotation, BeanManager beanManager)
          Inspect AnnoatedElement element for a specific type of annotation.
static Set<Annotation> getAnnotations(Annotated element, Class<? extends Annotation> metaAnnotationType)
          Inspects an annotated element for any annotations with the given meta annotation.
static
<A extends Annotation>
A
getMetaAnnotation(Annotated element, Class<A> annotationType)
          Inspects an annotated element for the given meta annotation.
static boolean isAnnotationPresent(AnnotatedElement element, Class<? extends Annotation> annotationType, boolean metaAnnotation, BeanManager beanManager)
          Discover if a AnnotatedElement element has been annotated with annotationType.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

isAnnotationPresent

public static boolean isAnnotationPresent(AnnotatedElement element,
                                          Class<? extends Annotation> annotationType,
                                          boolean metaAnnotation,
                                          BeanManager beanManager)
Discover if a AnnotatedElement element has been annotated with annotationType. This also discovers annotations defined through a @ Stereotype and the CDI SPI.

Parameters:
element - The element to inspect.
annotationType -
metaAnnotation - Whether the annotation may be used as a meta-annotation or not
Returns:
true if annotation is present either on the method itself. Returns false if the annotation is not present
Throws:
IllegalArgumentException - if element or annotationType is null

getAnnotation

public static <A extends Annotation> A getAnnotation(AnnotatedElement element,
                                                     Class<A> annotationType,
                                                     boolean metaAnnotation,
                                                     BeanManager beanManager)
Inspect AnnoatedElement element for a specific type of annotation. This also discovers annotations defined through a @ Stereotype and the CDI SPI.

Parameters:
element - The element to inspect
annotationType - The annotation type to check for
metaAnnotation - Whether the annotation may be used as a meta-annotation or not
Returns:
The annotation instance found on this method or null if no matching annotation was found.
Throws:
IllegalArgumentException - if element or annotationType is null

getMetaAnnotation

public static <A extends Annotation> A getMetaAnnotation(Annotated element,
                                                         Class<A> annotationType)
Inspects an annotated element for the given meta annotation. This should only be used for user defined meta annotations, where the annotation must be physically present.

Parameters:
element - The element to inspect
annotationType - The meta annotation to search for
Returns:
The annotation instance found on this method or null if no matching annotation was found.

getAnnotations

public static Set<Annotation> getAnnotations(Annotated element,
                                             Class<? extends Annotation> metaAnnotationType)
Inspects an annotated element for any annotations with the given meta annotation. This should only be used for user defined meta annotations, where the annotation must be physically present.

Parameters:
element - The element to inspect
annotationType - The meta annotation to search for
Returns:
The annotation instances found on this method or an empty set if no matching meta-annotation was found.


Copyright © 2008-2010 Seam Framework. All Rights Reserved.