org.apache.webbeans.util
Class AnnotationUtil

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

public final class AnnotationUtil
extends java.lang.Object

Utility class related with Annotation operations.

Since:
1.0
Author:
Gurkan Erdogdu

Field Summary
static java.lang.annotation.Annotation[] EMPTY_ANNOTATION_ARRAY
           
static java.lang.Object[] EMPTY_OBJECT_ARRAY
           
 
Method Summary
static
<X,T extends java.lang.annotation.Annotation>
T
getAnnotatedMethodFirstParameterAnnotation(javax.enterprise.inject.spi.AnnotatedMethod<X> annotatedMethod, java.lang.Class<T> clazz)
           
static
<X> java.lang.annotation.Annotation[]
getAnnotatedMethodFirstParameterQualifierWithGivenAnnotation(javax.enterprise.inject.spi.AnnotatedMethod<X> annotatedMethod, java.lang.Class<? extends java.lang.annotation.Annotation> clazz)
          Deprecated. 
static
<X> java.lang.reflect.Type
getAnnotatedMethodFirstParameterWithAnnotation(javax.enterprise.inject.spi.AnnotatedMethod<X> annotatedMethod, java.lang.Class<? extends java.lang.annotation.Annotation> clazz)
           
static
<T extends java.lang.annotation.Annotation>
T
getAnnotation(java.lang.annotation.Annotation[] anns, java.lang.Class<T> annotation)
          get the annotation of the given type from the array.
static java.lang.annotation.Annotation[] getAnnotationsFromSet(java.util.Set<java.lang.annotation.Annotation> set)
           
static java.lang.reflect.Type[] getConstructorParameterGenericTypesWithGivenAnnotation(java.lang.reflect.Constructor<?> constructor, java.lang.Class<? extends java.lang.annotation.Annotation> clazz)
           
static java.lang.annotation.Annotation[] getInterceptorBindingMetaAnnotations(java.lang.annotation.Annotation[] anns)
          Deprecated. 
static java.lang.annotation.Annotation[] getMetaAnnotations(java.lang.annotation.Annotation[] anns, java.lang.Class<? extends java.lang.annotation.Annotation> metaAnnotation)
          Returns a subset of annotations that are annotated with the specified meta-annotation
static
<T extends java.lang.annotation.Annotation>
T
getMethodFirstParameterAnnotation(java.lang.reflect.Method method, java.lang.Class<T> clazz)
          Gets the method first found parameter annotation with given type.
static java.lang.annotation.Annotation[] getMethodFirstParameterQualifierWithGivenAnnotation(java.lang.reflect.Method method, java.lang.Class<? extends java.lang.annotation.Annotation> clazz)
          Deprecated. 
static java.lang.Class<?> getMethodFirstParameterTypeClazzWithAnnotation(java.lang.reflect.Method method, java.lang.Class<? extends java.lang.annotation.Annotation> clazz)
           
static java.lang.reflect.Type getMethodFirstParameterWithAnnotation(java.lang.reflect.Method method, java.lang.Class<? extends java.lang.annotation.Annotation> clazz)
          Gets the method first found parameter type that is annotated with the given annotation.
static java.lang.reflect.Type[] getMethodParameterGenericTypesWithGivenAnnotation(java.lang.reflect.Method method, java.lang.Class<? extends java.lang.annotation.Annotation> clazz)
           
static java.lang.reflect.Method[] getMethodsWithParameterAnnotation(java.lang.Class<?> clazz, java.lang.Class<? extends java.lang.annotation.Annotation> annotation)
          Gets array of methods that has parameter with given annotation type.
static java.lang.annotation.Annotation[] getQualifierAnnotations(java.lang.annotation.Annotation... annotations)
          Deprecated. 
static java.lang.annotation.Annotation[] getRealizesGenericAnnotations(java.lang.Class<?> clazz, java.lang.annotation.Annotation[] anns)
          Deprecated. 
static java.lang.annotation.Annotation[] getStereotypeMetaAnnotations(java.lang.annotation.Annotation[] anns)
          Deprecated. 
static java.lang.reflect.Type getTypeOfParameterWithGivenAnnotation(java.lang.reflect.Method method, java.lang.Class<? extends java.lang.annotation.Annotation> clazz)
          Get the Type of the method parameter which has the given annotation
static
<X> boolean
hasAnnotatedMethodMultipleParameterAnnotation(javax.enterprise.inject.spi.AnnotatedMethod<X> annotatedMethod, java.lang.Class<? extends java.lang.annotation.Annotation> clazz)
           
static
<X> boolean
hasAnnotatedMethodParameterAnnotation(javax.enterprise.inject.spi.AnnotatedMethod<X> annotatedMethod, java.lang.Class<? extends java.lang.annotation.Annotation> clazz)
           
static boolean hasAnnotation(java.lang.annotation.Annotation[] anns, java.lang.Class<? extends java.lang.annotation.Annotation> annotation)
           
static boolean hasAnyQualifier(javax.enterprise.inject.spi.Bean<?> bean)
          Returns true if any binding exist
static boolean hasClassAnnotation(java.lang.Class<?> clazz, java.lang.Class<? extends java.lang.annotation.Annotation> annotation)
          Check whether or not class contains the given annotation.
static boolean hasInterceptorBindingMetaAnnotation(java.lang.annotation.Annotation[] anns)
          Deprecated. 
static boolean hasMetaAnnotation(java.lang.annotation.Annotation[] anns, java.lang.Class<? extends java.lang.annotation.Annotation> metaAnnotation)
           
static boolean hasMethodAnnotation(java.lang.reflect.Method method, java.lang.Class<? extends java.lang.annotation.Annotation> clazz)
          Check given annotation exist on the method.
static boolean hasMethodMultipleParameterAnnotation(java.lang.reflect.Method method, java.lang.Class<? extends java.lang.annotation.Annotation> clazz)
          Check given annotation exist in the multiple parameter of the given method.
static boolean hasMethodParameterAnnotation(java.lang.reflect.Method method, java.lang.Class<? extends java.lang.annotation.Annotation> clazz)
          Check given annotation exist in the any parameter of the given method.
static boolean hasMethodParameterAnnotationCrossRef(java.lang.reflect.Method method, java.lang.Class<? extends java.lang.annotation.Annotation> clazz)
          Check given annotation cross ref exist in the any parameter of the given method.
static java.lang.annotation.Annotation hasOwbInjectableResource(java.lang.annotation.Annotation[] annotations)
           
static boolean hasStereoTypeMetaAnnotation(java.lang.annotation.Annotation[] anns)
          Deprecated. 
static boolean isInterceptorBindingAnnotation(java.lang.Class<? extends java.lang.annotation.Annotation> clazz)
          Deprecated. 
static boolean isQualifierEqual(java.lang.annotation.Annotation qualifier1, java.lang.annotation.Annotation qualifier2)
          Checks if the given qualifiers are equal.
static boolean isStereoTypeAnnotation(java.lang.Class<? extends java.lang.annotation.Annotation> clazz)
          Deprecated. 
 
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 java.lang.annotation.Annotation[] EMPTY_ANNOTATION_ARRAY

EMPTY_OBJECT_ARRAY

public static final java.lang.Object[] EMPTY_OBJECT_ARRAY
Method Detail

hasMethodAnnotation

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

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

hasMethodParameterAnnotation

public static boolean hasMethodParameterAnnotation(java.lang.reflect.Method method,
                                                   java.lang.Class<? extends java.lang.annotation.Annotation> clazz)
Check given annotation exist in the any parameter of the given method. Return true if exist false otherwise.

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

hasAnnotatedMethodParameterAnnotation

public static <X> boolean hasAnnotatedMethodParameterAnnotation(javax.enterprise.inject.spi.AnnotatedMethod<X> annotatedMethod,
                                                                java.lang.Class<? extends java.lang.annotation.Annotation> clazz)

getMethodParameterGenericTypesWithGivenAnnotation

public static java.lang.reflect.Type[] getMethodParameterGenericTypesWithGivenAnnotation(java.lang.reflect.Method method,
                                                                                         java.lang.Class<? extends java.lang.annotation.Annotation> clazz)

getConstructorParameterGenericTypesWithGivenAnnotation

public static java.lang.reflect.Type[] getConstructorParameterGenericTypesWithGivenAnnotation(java.lang.reflect.Constructor<?> constructor,
                                                                                              java.lang.Class<? extends java.lang.annotation.Annotation> clazz)

hasMethodMultipleParameterAnnotation

public static boolean hasMethodMultipleParameterAnnotation(java.lang.reflect.Method method,
                                                           java.lang.Class<? extends java.lang.annotation.Annotation> clazz)
Check given annotation exist in the multiple parameter of the given method. Return true if exist false otherwise.

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

hasAnnotatedMethodMultipleParameterAnnotation

public static <X> boolean hasAnnotatedMethodMultipleParameterAnnotation(javax.enterprise.inject.spi.AnnotatedMethod<X> annotatedMethod,
                                                                        java.lang.Class<? extends java.lang.annotation.Annotation> clazz)

getMethodFirstParameterWithAnnotation

public static java.lang.reflect.Type getMethodFirstParameterWithAnnotation(java.lang.reflect.Method method,
                                                                           java.lang.Class<? extends java.lang.annotation.Annotation> clazz)
Gets the method first found parameter type that is annotated with the given annotation.

Parameters:
method - method
clazz - checking annotation
Returns:
type

getAnnotatedMethodFirstParameterWithAnnotation

public static <X> java.lang.reflect.Type getAnnotatedMethodFirstParameterWithAnnotation(javax.enterprise.inject.spi.AnnotatedMethod<X> annotatedMethod,
                                                                                        java.lang.Class<? extends java.lang.annotation.Annotation> clazz)

getAnnotatedMethodFirstParameterQualifierWithGivenAnnotation

@Deprecated
public static <X> java.lang.annotation.Annotation[] getAnnotatedMethodFirstParameterQualifierWithGivenAnnotation(javax.enterprise.inject.spi.AnnotatedMethod<X> annotatedMethod,
                                                                                                                            java.lang.Class<? extends java.lang.annotation.Annotation> clazz)
Deprecated. 


getMethodFirstParameterTypeClazzWithAnnotation

public static java.lang.Class<?> getMethodFirstParameterTypeClazzWithAnnotation(java.lang.reflect.Method method,
                                                                                java.lang.Class<? extends java.lang.annotation.Annotation> clazz)

getMethodFirstParameterQualifierWithGivenAnnotation

@Deprecated
public static java.lang.annotation.Annotation[] getMethodFirstParameterQualifierWithGivenAnnotation(java.lang.reflect.Method method,
                                                                                                               java.lang.Class<? extends java.lang.annotation.Annotation> clazz)
Deprecated. 

Gets the method first found parameter qualifiers.

Parameters:
method - method
clazz - checking annotation
Returns:
annotation array

getTypeOfParameterWithGivenAnnotation

public static java.lang.reflect.Type getTypeOfParameterWithGivenAnnotation(java.lang.reflect.Method method,
                                                                           java.lang.Class<? extends java.lang.annotation.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.

getMethodFirstParameterAnnotation

public static <T extends java.lang.annotation.Annotation> T getMethodFirstParameterAnnotation(java.lang.reflect.Method method,
                                                                                              java.lang.Class<T> clazz)
Gets the method first found parameter annotation with given type.

Parameters:
method - method
clazz - checking annotation
Returns:
annotation

getAnnotatedMethodFirstParameterAnnotation

public static <X,T extends java.lang.annotation.Annotation> T getAnnotatedMethodFirstParameterAnnotation(javax.enterprise.inject.spi.AnnotatedMethod<X> annotatedMethod,
                                                                                                         java.lang.Class<T> clazz)

hasMethodParameterAnnotationCrossRef

public static boolean hasMethodParameterAnnotationCrossRef(java.lang.reflect.Method method,
                                                           java.lang.Class<? extends java.lang.annotation.Annotation> clazz)
Check given annotation cross ref exist in the any parameter of the given method. Return true if exist false otherwise.

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

isQualifierEqual

public static boolean isQualifierEqual(java.lang.annotation.Annotation qualifier1,
                                       java.lang.annotation.Annotation qualifier2)
Checks if the given qualifiers are equal. Qualifiers are equal if they have the same annotationType and all their methods, except those annotated with @Nonbinding, return the same value.

Parameters:
qualifier1 -
qualifier2 -
Returns:

getQualifierAnnotations

@Deprecated
public static java.lang.annotation.Annotation[] getQualifierAnnotations(java.lang.annotation.Annotation... annotations)
Deprecated. 

Gets the array of qualifier annotations on the given array.

Parameters:
annotations - annotation array
Returns:
array containing qualifier anns

getMethodsWithParameterAnnotation

public static java.lang.reflect.Method[] getMethodsWithParameterAnnotation(java.lang.Class<?> clazz,
                                                                           java.lang.Class<? extends java.lang.annotation.Annotation> annotation)
Gets array of methods that has parameter with given annotation type.

Parameters:
clazz - class for check
annotation - for check
Returns:
array of methods

hasClassAnnotation

public static boolean hasClassAnnotation(java.lang.Class<?> clazz,
                                         java.lang.Class<? extends java.lang.annotation.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(java.lang.annotation.Annotation[] anns,
                                        java.lang.Class<? extends java.lang.annotation.Annotation> metaAnnotation)

hasAnnotation

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

getAnnotation

public static <T extends java.lang.annotation.Annotation> T getAnnotation(java.lang.annotation.Annotation[] anns,
                                                                          java.lang.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 java.lang.annotation.Annotation[] getMetaAnnotations(java.lang.annotation.Annotation[] anns,
                                                                   java.lang.Class<? extends java.lang.annotation.Annotation> metaAnnotation)
Returns a subset of annotations that are annotated with the specified meta-annotation

Parameters:
anns -
metaAnnotation -
Returns:

hasAnyQualifier

public static boolean hasAnyQualifier(javax.enterprise.inject.spi.Bean<?> bean)
Returns true if any binding exist

Parameters:
bean - bean
Returns:
true if any binding exist

hasOwbInjectableResource

public static java.lang.annotation.Annotation hasOwbInjectableResource(java.lang.annotation.Annotation[] annotations)

isInterceptorBindingAnnotation

@Deprecated
public static boolean isInterceptorBindingAnnotation(java.lang.Class<? extends java.lang.annotation.Annotation> clazz)
Deprecated. 

Returns true if the annotation is defined in xml or annotated with InterceptorBinding false otherwise.

Parameters:
clazz - type of the annotation
Returns:
true if the annotation is defined in xml or annotated with InterceptorBinding false otherwise

hasInterceptorBindingMetaAnnotation

@Deprecated
public static boolean hasInterceptorBindingMetaAnnotation(java.lang.annotation.Annotation[] anns)
Deprecated. 

If any Annotations in the input is an interceptor binding annotation type then return true, false otherwise.

Parameters:
anns - array of Annotations to check
Returns:
true if one or moe of the input annotations are an interceptor binding annotation type false otherwise

getInterceptorBindingMetaAnnotations

@Deprecated
public static java.lang.annotation.Annotation[] getInterceptorBindingMetaAnnotations(java.lang.annotation.Annotation[] anns)
Deprecated. 

Collect the interceptor bindings from an array of annotations, including transitively defined interceptor bindings.

Parameters:
anns - An array of annotations
Returns:
an array of interceptor binding annotations, including the input and any transitively declared annotations

getStereotypeMetaAnnotations

@Deprecated
public static java.lang.annotation.Annotation[] getStereotypeMetaAnnotations(java.lang.annotation.Annotation[] anns)
Deprecated. 


hasStereoTypeMetaAnnotation

@Deprecated
public static boolean hasStereoTypeMetaAnnotation(java.lang.annotation.Annotation[] anns)
Deprecated. 


isStereoTypeAnnotation

@Deprecated
public static boolean isStereoTypeAnnotation(java.lang.Class<? extends java.lang.annotation.Annotation> clazz)
Deprecated. 

Returns true if the annotation is defined in xml or annotated with Stereotype false otherwise.

Parameters:
clazz - type of the annotation
Returns:
true if the annotation is defined in xml or annotated with Stereotype false otherwise

getRealizesGenericAnnotations

@Deprecated
public static java.lang.annotation.Annotation[] getRealizesGenericAnnotations(java.lang.Class<?> clazz,
                                                                                         java.lang.annotation.Annotation[] anns)
Deprecated. 

If the bean extends generic class via Realizes annotation, realized based producer methods, fields and observer methods qualifier is

Parameters:
clazz - realized definition class
anns - binding annotations array

getAnnotationsFromSet

public static java.lang.annotation.Annotation[] getAnnotationsFromSet(java.util.Set<java.lang.annotation.Annotation> set)


Copyright © 2008-2011 The Apache Software Foundation. All Rights Reserved.