org.jboss.weld.util.reflection
Class Reflections

java.lang.Object
  extended by org.jboss.weld.util.reflection.Reflections

public class Reflections
extends java.lang.Object

Utility class for static reflection-type operations

Author:
Pete Muir

Field Summary
static java.lang.annotation.Annotation[] EMPTY_ANNOTATIONS
           
static java.lang.Class<?>[] EMPTY_CLASSES
           
static java.lang.reflect.Type[] EMPTY_TYPES
           
 
Constructor Summary
Reflections()
           
 
Method Summary
static java.util.Map<java.lang.Class<?>,java.lang.reflect.Type> buildTypeMap(java.util.Set<java.lang.reflect.Type> types)
           
static boolean containsWildcards(java.lang.reflect.Type[] types)
           
static java.lang.reflect.Type[] getActualTypeArguments(java.lang.Class<?> clazz)
          Gets the actual type arguments of a class
static int getNesting(java.lang.Class<?> clazz)
           
static java.lang.String getPropertyName(java.lang.reflect.Method method)
          Gets the property name from a getter method.
static
<T> java.lang.Class<T>
getRawType(java.lang.reflect.Type type)
           
static boolean isAbstract(java.lang.reflect.Method method)
          Checks if a method is abstract
static boolean isArrayType(java.lang.Class<?> rawType)
          Checks if raw type is array type
static boolean isAssignableFrom(java.lang.Class<?> rawType1, java.lang.reflect.Type[] actualTypeArguments1, java.lang.Class<?> rawType2, java.lang.reflect.Type[] actualTypeArguments2)
          Check the assignability of one type to another, taking into account the actual type arguements
static boolean isAssignableFrom(java.lang.Class<?> rawType1, java.lang.reflect.Type[] actualTypeArguments1, java.lang.reflect.Type type2)
           
static boolean isAssignableFrom(java.util.Set<java.lang.reflect.Type> types1, java.util.Set<java.lang.reflect.Type> types2)
          Check the assiginability of a set of flattened types.
static boolean isAssignableFrom(java.util.Set<java.lang.reflect.Type> types1, java.lang.reflect.Type type2)
          Check the assiginability of a set of flattened types.
static boolean isAssignableFrom(java.lang.reflect.Type[] types1, java.lang.reflect.Type type2)
           
static boolean isAssignableFrom(java.lang.reflect.Type[] actualTypeArguments1, java.lang.reflect.Type[] actualTypeArguments2)
           
static boolean isAssignableFrom(java.lang.reflect.Type type1, java.util.Set<? extends java.lang.reflect.Type> types2)
           
static boolean isAssignableFrom(java.lang.reflect.Type type1, java.lang.reflect.Type type2)
           
static boolean isAssignableFrom(java.lang.reflect.Type type1, java.lang.reflect.Type[] types2)
           
static boolean isBindings(java.lang.annotation.Annotation binding)
          Deprecated. 
static boolean isFinal(java.lang.Class<?> clazz)
          Checks if class is final
static boolean isFinal(java.lang.reflect.Member member)
          Checks if member is final
static boolean isPackagePrivate(int mod)
           
static boolean isParamerterizedTypeWithWildcard(java.lang.Class<?> type)
           
static boolean isParameterizedType(java.lang.Class<?> type)
          Checks if type is parameterized type
static boolean isSerializable(java.lang.Class<?> clazz)
           
static boolean isStatic(java.lang.Class<?> type)
          Checks if type is static
static boolean isStatic(java.lang.reflect.Member member)
          Checks if member is static
static boolean isTransient(java.lang.reflect.Member member)
           
static boolean isTypeBounded(java.lang.reflect.Type type, java.lang.reflect.Type[] lowerBounds, java.lang.reflect.Type[] upperBounds)
           
static boolean isTypeOrAnyMethodFinal(java.lang.Class<?> type)
          Checks if type or member is final
static boolean matches(java.lang.Class<?> rawType1, java.lang.reflect.Type[] actualTypeArguments1, java.lang.Class<?> rawType2, java.lang.reflect.Type[] actualTypeArguments2)
           
static boolean matches(java.lang.Class<?> rawType1, java.lang.reflect.Type[] actualTypeArguments1, java.lang.reflect.Type type2)
           
static boolean matches(java.util.Set<java.lang.reflect.Type> types1, java.util.Set<java.lang.reflect.Type> types2)
          Check whether whether any of the types1 matches a type in types2
static boolean matches(java.lang.reflect.Type type1, java.util.Set<? extends java.lang.reflect.Type> types2)
           
static boolean matches(java.lang.reflect.Type type1, java.lang.reflect.Type type2)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

EMPTY_TYPES

public static final java.lang.reflect.Type[] EMPTY_TYPES

EMPTY_ANNOTATIONS

public static final java.lang.annotation.Annotation[] EMPTY_ANNOTATIONS

EMPTY_CLASSES

public static final java.lang.Class<?>[] EMPTY_CLASSES
Constructor Detail

Reflections

public Reflections()
Method Detail

buildTypeMap

public static java.util.Map<java.lang.Class<?>,java.lang.reflect.Type> buildTypeMap(java.util.Set<java.lang.reflect.Type> types)

getPropertyName

public static java.lang.String getPropertyName(java.lang.reflect.Method method)
Gets the property name from a getter method. We extend JavaBean conventions, allowing the getter method to have parameters

Parameters:
method - The getter method
Returns:
The name of the property. Returns null if method wasn't JavaBean getter-styled

isFinal

public static boolean isFinal(java.lang.Class<?> clazz)
Checks if class is final

Parameters:
clazz - The class to check
Returns:
True if final, false otherwise

getNesting

public static int getNesting(java.lang.Class<?> clazz)

isFinal

public static boolean isFinal(java.lang.reflect.Member member)
Checks if member is final

Parameters:
member - The member to check
Returns:
True if final, false otherwise

isTypeOrAnyMethodFinal

public static boolean isTypeOrAnyMethodFinal(java.lang.Class<?> type)
Checks if type or member is final

Parameters:
type - Type or member
Returns:
True if final, false otherwise

isPackagePrivate

public static boolean isPackagePrivate(int mod)

isStatic

public static boolean isStatic(java.lang.Class<?> type)
Checks if type is static

Parameters:
type - Type to check
Returns:
True if static, false otherwise

isStatic

public static boolean isStatic(java.lang.reflect.Member member)
Checks if member is static

Parameters:
member - Member to check
Returns:
True if static, false otherwise

isTransient

public static boolean isTransient(java.lang.reflect.Member member)

isAbstract

public static boolean isAbstract(java.lang.reflect.Method method)
Checks if a method is abstract

Parameters:
method -
Returns:

getActualTypeArguments

public static java.lang.reflect.Type[] getActualTypeArguments(java.lang.Class<?> clazz)
Gets the actual type arguments of a class

Parameters:
clazz - The class to examine
Returns:
The type arguments

isArrayType

public static boolean isArrayType(java.lang.Class<?> rawType)
Checks if raw type is array type

Parameters:
rawType - The raw type to check
Returns:
True if array, false otherwise

isParameterizedType

public static boolean isParameterizedType(java.lang.Class<?> type)
Checks if type is parameterized type

Parameters:
type - The type to check
Returns:
True if parameterized, false otherwise

isParamerterizedTypeWithWildcard

public static boolean isParamerterizedTypeWithWildcard(java.lang.Class<?> type)

containsWildcards

public static boolean containsWildcards(java.lang.reflect.Type[] types)

isBindings

@Deprecated
public static boolean isBindings(java.lang.annotation.Annotation binding)
Deprecated. 

Checks the bindingType to make sure the annotation was declared properly as a binding type (annotated with @BindingType) and that it has a runtime retention policy.

Parameters:
binding - The binding type to check
Returns:
true only if the annotation is really a binding type

isAssignableFrom

public static boolean isAssignableFrom(java.lang.Class<?> rawType1,
                                       java.lang.reflect.Type[] actualTypeArguments1,
                                       java.lang.Class<?> rawType2,
                                       java.lang.reflect.Type[] actualTypeArguments2)
Check the assignability of one type to another, taking into account the actual type arguements

Parameters:
rawType1 - the raw type of the class to check
actualTypeArguments1 - the actual type arguements to check, or an empty array if not a parameterized type
rawType2 - the raw type of the class to check
actualTypeArguments2 - the actual type arguements to check, or an empty array if not a parameterized type
Returns:

matches

public static boolean matches(java.lang.Class<?> rawType1,
                              java.lang.reflect.Type[] actualTypeArguments1,
                              java.lang.Class<?> rawType2,
                              java.lang.reflect.Type[] actualTypeArguments2)

isAssignableFrom

public static boolean isAssignableFrom(java.lang.reflect.Type[] actualTypeArguments1,
                                       java.lang.reflect.Type[] actualTypeArguments2)

isAssignableFrom

public static boolean isAssignableFrom(java.lang.reflect.Type type1,
                                       java.util.Set<? extends java.lang.reflect.Type> types2)

matches

public static boolean matches(java.lang.reflect.Type type1,
                              java.util.Set<? extends java.lang.reflect.Type> types2)

isAssignableFrom

public static boolean isAssignableFrom(java.lang.reflect.Type type1,
                                       java.lang.reflect.Type[] types2)

isAssignableFrom

public static boolean isAssignableFrom(java.lang.reflect.Type type1,
                                       java.lang.reflect.Type type2)

matches

public static boolean matches(java.lang.reflect.Type type1,
                              java.lang.reflect.Type type2)

isTypeBounded

public static boolean isTypeBounded(java.lang.reflect.Type type,
                                    java.lang.reflect.Type[] lowerBounds,
                                    java.lang.reflect.Type[] upperBounds)

isAssignableFrom

public static boolean isAssignableFrom(java.lang.Class<?> rawType1,
                                       java.lang.reflect.Type[] actualTypeArguments1,
                                       java.lang.reflect.Type type2)

matches

public static boolean matches(java.lang.Class<?> rawType1,
                              java.lang.reflect.Type[] actualTypeArguments1,
                              java.lang.reflect.Type type2)

isAssignableFrom

public static boolean isAssignableFrom(java.util.Set<java.lang.reflect.Type> types1,
                                       java.util.Set<java.lang.reflect.Type> types2)
Check the assiginability of a set of flattened types. This algorithm will check whether any of the types1 matches a type in types2

Parameters:
types1 -
types2 -
Returns:

matches

public static boolean matches(java.util.Set<java.lang.reflect.Type> types1,
                              java.util.Set<java.lang.reflect.Type> types2)
Check whether whether any of the types1 matches a type in types2

Parameters:
types1 -
types2 -
Returns:

isAssignableFrom

public static boolean isAssignableFrom(java.util.Set<java.lang.reflect.Type> types1,
                                       java.lang.reflect.Type type2)
Check the assiginability of a set of flattened types. This algorithm will check whether any of the types1 matches a type in types2

Parameters:
types1 -
types2 -
Returns:

isAssignableFrom

public static boolean isAssignableFrom(java.lang.reflect.Type[] types1,
                                       java.lang.reflect.Type type2)

isSerializable

public static boolean isSerializable(java.lang.Class<?> clazz)

getRawType

public static <T> java.lang.Class<T> getRawType(java.lang.reflect.Type type)


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