org.apache.webbeans.util
Class AnnotationUtil

java.lang.Object
  extended by org.apache.webbeans.util.AnnotationUtil

public final class AnnotationUtil
extends Object

Utility class related with Annotation operations.

Since:
1.0
Author:
Gurkan Erdogdu

Field Summary
static Set<Annotation> DEFAULT_AND_ANY_ANNOTATION
           
static Annotation[] EMPTY_ANNOTATION_ARRAY
           
static Object[] EMPTY_OBJECT_ARRAY
           
 
Method Summary
static Annotation[] asArray(Set<Annotation> set)
           
static
<X,T extends Annotation>
T
getAnnotatedMethodFirstParameterAnnotation(AnnotatedMethod<X> annotatedMethod, Class<T> clazz)
           
static
<X> Type
getAnnotatedMethodFirstParameterWithAnnotation(AnnotatedMethod<X> annotatedMethod, Class<? extends Annotation> clazz)
           
static
<T extends Annotation>
T
getAnnotation(Annotation[] anns, Class<T> annotation)
          get the annotation of the given type from the array.
static
<T extends Annotation>
T
getAnnotation(Set<Annotation> annotations, Class<T> annotationClass)
          Search in the given Set of Annotations for the one with the given AnnotationClass.
static int getCdiAnnotationHashCode(Annotation annotation)
          Computes a hash code for the specified cdi annoation. cdi annotations may either be qualifiers or interceptor bindings.
static Class<?> getDeclaringClass(Annotation declaredAnnotation, Class<?> typeHierarchy)
          Returns the declaring class for the specified annotation, using the specified type hierarchy.
static Annotation[] getMetaAnnotations(Annotation[] anns, Class<? extends Annotation> metaAnnotation)
          Returns a subset of annotations that are annotated with the specified meta-annotation
static Type getTypeOfParameterWithGivenAnnotation(Method method, Class<? extends Annotation> clazz)
          Get the Type of the method parameter which has the given annotation
static
<X> boolean
hasAnnotatedMethodMultipleParameterAnnotation(AnnotatedMethod<X> annotatedMethod, Class<? extends Annotation> clazz)
           
static
<X> boolean
hasAnnotatedMethodParameterAnnotation(AnnotatedMethod<X> annotatedMethod, Class<? extends Annotation> clazz)
           
static boolean hasAnnotation(Annotation[] anns, Class<? extends Annotation> annotation)
           
static boolean hasClassAnnotation(Class<?> clazz, Class<? extends Annotation> annotation)
          Check whether or not class contains the given annotation.
static boolean hasMetaAnnotation(Annotation[] anns, Class<? extends Annotation> metaAnnotation)
           
static boolean hasMethodAnnotation(Method method, Class<? extends Annotation> clazz)
          Check given annotation exist on the method.
static Annotation hasOwbInjectableResource(Annotation[] annotations)
           
static boolean isCdiAnnotationEqual(Annotation annotation1, Annotation annotation2)
          Checks if the given cdi annotations are equal. cdi annotations may either be qualifiers or interceptor bindings.
static boolean isDeclaringClass(Class<?> declaringClass, Annotation declaredAnnotation)
          Checks, if the given class declares the specified annotation
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

EMPTY_ANNOTATION_ARRAY

public static final Annotation[] EMPTY_ANNOTATION_ARRAY

EMPTY_OBJECT_ARRAY

public static final Object[] EMPTY_OBJECT_ARRAY

DEFAULT_AND_ANY_ANNOTATION

public static final Set<Annotation> DEFAULT_AND_ANY_ANNOTATION
Method Detail

isDeclaringClass

public static boolean isDeclaringClass(Class<?> declaringClass,
                                       Annotation declaredAnnotation)
Checks, if the given class declares the specified annotation


getDeclaringClass

public static Class<?> getDeclaringClass(Annotation declaredAnnotation,
                                         Class<?> typeHierarchy)
Returns the declaring class for the specified annotation, using the specified type hierarchy.


hasMethodAnnotation

public static boolean hasMethodAnnotation(Method method,
                                          Class<? extends Annotation> clazz)
Check given annotation exist on the method.

Parameters:
method - method
clazz - annotation class
Returns:
true or false

hasAnnotatedMethodParameterAnnotation

public static <X> boolean hasAnnotatedMethodParameterAnnotation(AnnotatedMethod<X> annotatedMethod,
                                                                Class<? extends Annotation> clazz)

hasAnnotatedMethodMultipleParameterAnnotation

public static <X> boolean hasAnnotatedMethodMultipleParameterAnnotation(AnnotatedMethod<X> annotatedMethod,
                                                                        Class<? extends Annotation> clazz)

getAnnotatedMethodFirstParameterWithAnnotation

public static <X> Type getAnnotatedMethodFirstParameterWithAnnotation(AnnotatedMethod<X> annotatedMethod,
                                                                      Class<? extends Annotation> clazz)

getTypeOfParameterWithGivenAnnotation

public static Type getTypeOfParameterWithGivenAnnotation(Method method,
                                                         Class<? extends Annotation> clazz)
Get the Type of the method parameter which has the given annotation

Parameters:
method - which need to be scanned
clazz - the annotation to scan the method parameters for
Returns:
the Type of the method parameter which has the given annotation, or null if not found.

getAnnotatedMethodFirstParameterAnnotation

public static <X,T extends Annotation> T getAnnotatedMethodFirstParameterAnnotation(AnnotatedMethod<X> annotatedMethod,
                                                                                    Class<T> clazz)

isCdiAnnotationEqual

public static boolean isCdiAnnotationEqual(Annotation annotation1,
                                           Annotation annotation2)
Checks if the given cdi annotations are equal. cdi annotations may either be qualifiers or interceptor bindings. CDI annotations are equal if they have the same annotationType and all their methods, except those annotated with @Nonbinding, return the same value.

Parameters:
annotation1 -
annotation2 -
Returns:

getCdiAnnotationHashCode

public static int getCdiAnnotationHashCode(Annotation annotation)
Computes a hash code for the specified cdi annoation. cdi annotations may either be qualifiers or interceptor bindings. The hash code of CDI annotations consists of the hash code of the annotationType and all its method values, except those annotated with @Nonbinding.

Parameters:
annotation -
Returns:

hasClassAnnotation

public static boolean hasClassAnnotation(Class<?> clazz,
                                         Class<? extends Annotation> annotation)
Check whether or not class contains the given annotation.

Parameters:
clazz - class instance
annotation - annotation class
Returns:
return true or false

hasMetaAnnotation

public static boolean hasMetaAnnotation(Annotation[] anns,
                                        Class<? extends Annotation> metaAnnotation)

hasAnnotation

public static boolean hasAnnotation(Annotation[] anns,
                                    Class<? extends Annotation> annotation)

getAnnotation

public static <T extends Annotation> T getAnnotation(Annotation[] anns,
                                                     Class<T> annotation)
get the annotation of the given type from the array.

Parameters:
anns -
annotation -
Returns:
the Annotation with the given type or null if no such found.

getMetaAnnotations

public static Annotation[] getMetaAnnotations(Annotation[] anns,
                                              Class<? extends Annotation> metaAnnotation)
Returns a subset of annotations that are annotated with the specified meta-annotation

Parameters:
anns -
metaAnnotation -
Returns:

getAnnotation

public static <T extends Annotation> T getAnnotation(Set<Annotation> annotations,
                                                     Class<T> annotationClass)
Search in the given Set of Annotations for the one with the given AnnotationClass.

Parameters:
annotations - to scan
annotationClass - to search for
Returns:
the annotation with the given annotationClass or null if not found.

hasOwbInjectableResource

public static Annotation hasOwbInjectableResource(Annotation[] annotations)

asArray

public static Annotation[] asArray(Set<Annotation> set)


Copyright © 2008–2014 The Apache Software Foundation. All rights reserved.