org.jboss.weld.util.reflection
Class Reflections

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

public class Reflections
extends Object

Utility class for static reflection-type operations

Author:
Pete Muir, Ales Justin, Marko Luksa

Field Summary
static Annotation[] EMPTY_ANNOTATIONS
           
static Class<?>[] EMPTY_CLASSES
           
static Type[] EMPTY_TYPES
           
 
Constructor Summary
Reflections()
           
 
Method Summary
static Map<Class<?>,Type> buildTypeMap(Set<Type> types)
           
static
<T> T
cast(Object obj)
           
static boolean containsWildcards(Type[] types)
           
static Type[] getActualTypeArguments(Type type)
          Gets the actual type arguments of a Type
static int getNesting(Class<?> clazz)
           
static Object getNonPrivateFinalMethodOrType(Class<?> type)
           
static String getPropertyName(Method method)
          Gets the property name from a getter method.
static
<T> Class<T>
getRawType(Type type)
           
static boolean isAbstract(Method method)
          Checks if a method is abstract
static boolean isArrayType(Class<?> rawType)
          Checks if raw type is array type
static boolean isAssignableFrom(Set<Type> types1, Set<Type> types2)
          Check the assiginability of a set of flattened types.
static boolean isAssignableFrom(Set<Type> types1, Type type2)
          Check the assiginability of a set of flattened types.
static boolean isAssignableFrom(Type[] types1, Type type2)
           
static boolean isAssignableFrom(Type type1, Set<? extends Type> types2)
           
static boolean isAssignableFrom(Type type1, Type type2)
           
static boolean isAssignableFrom(Type type1, Type[] types2)
           
static boolean isAssignableTo(Type type1, Type[] types2)
           
static boolean isBindings(Annotation binding)
          Deprecated. 
static boolean isCacheable(Annotation[] annotations)
           
static boolean isCacheable(Set<Annotation> annotations)
           
static boolean isClassLoadable(String className, org.jboss.weld.resources.spi.ResourceLoader resourceLoader)
           
static boolean isFinal(Class<?> clazz)
          Checks if class is final
static boolean isFinal(Member member)
          Checks if member is final
static boolean isNonStaticInnerClass(Class<?> clazz)
           
static boolean isPackagePrivate(int mod)
           
static boolean isParamerterizedTypeWithWildcard(Class<?> type)
           
static boolean isParameterizedType(Class<?> type)
          Checks if type is parameterized type
static boolean isPrimitive(Type type)
           
static boolean isPrivate(Member member)
          Checks if member is private
static boolean isSerializable(Class<?> clazz)
           
static boolean isStatic(Class<?> type)
          Checks if type is static
static boolean isStatic(Member member)
          Checks if member is static
static boolean isTransient(Member member)
           
static boolean isTypeInsideBounds(Type type, Type[] lowerBounds, Type[] upperBounds)
           
static boolean isTypeOrAnyMethodFinal(Class<?> type)
          Checks if type or member is final
static boolean matches(Set<Type> requiredTypes, Set<Type> beanTypes)
          Check whether whether any of the requiredTypes matches a type in beanTypes
static boolean matches(Type requiredType, Set<? extends Type> beanTypes)
           
static boolean matches(Type requiredType, Type beanType)
           
 
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 Type[] EMPTY_TYPES

EMPTY_ANNOTATIONS

public static final Annotation[] EMPTY_ANNOTATIONS

EMPTY_CLASSES

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

Reflections

public Reflections()
Method Detail

buildTypeMap

public static Map<Class<?>,Type> buildTypeMap(Set<Type> types)

isCacheable

public static boolean isCacheable(Set<Annotation> annotations)

isCacheable

public static boolean isCacheable(Annotation[] annotations)

cast

public static <T> T cast(Object obj)

getPropertyName

public static String getPropertyName(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(Class<?> clazz)
Checks if class is final

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

getNesting

public static int getNesting(Class<?> clazz)

isNonStaticInnerClass

public static boolean isNonStaticInnerClass(Class<?> clazz)

isFinal

public static boolean isFinal(Member member)
Checks if member is final

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

isPrivate

public static boolean isPrivate(Member member)
Checks if member is private

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

isTypeOrAnyMethodFinal

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

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

getNonPrivateFinalMethodOrType

public static Object getNonPrivateFinalMethodOrType(Class<?> type)

isPackagePrivate

public static boolean isPackagePrivate(int mod)

isStatic

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

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

isStatic

public static boolean isStatic(Member member)
Checks if member is static

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

isTransient

public static boolean isTransient(Member member)

isAbstract

public static boolean isAbstract(Method method)
Checks if a method is abstract

Parameters:
method - the method
Returns:
true if abstract

getActualTypeArguments

public static Type[] getActualTypeArguments(Type type)
Gets the actual type arguments of a Type

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

isArrayType

public static boolean isArrayType(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(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(Class<?> type)

containsWildcards

public static boolean containsWildcards(Type[] types)

isBindings

@Deprecated
public static boolean isBindings(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(Type type1,
                                       Set<? extends Type> types2)

matches

public static boolean matches(Type requiredType,
                              Set<? extends Type> beanTypes)

isAssignableTo

public static boolean isAssignableTo(Type type1,
                                     Type[] types2)

isAssignableFrom

public static boolean isAssignableFrom(Type type1,
                                       Type[] types2)

isAssignableFrom

public static boolean isAssignableFrom(Type type1,
                                       Type type2)

matches

public static boolean matches(Type requiredType,
                              Type beanType)

isTypeInsideBounds

public static boolean isTypeInsideBounds(Type type,
                                         Type[] lowerBounds,
                                         Type[] upperBounds)

isAssignableFrom

public static boolean isAssignableFrom(Set<Type> types1,
                                       Set<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 - the types1
types2 - the type2
Returns:
can we assign any type from types1 to types2

matches

public static boolean matches(Set<Type> requiredTypes,
                              Set<Type> beanTypes)
Check whether whether any of the requiredTypes matches a type in beanTypes

Parameters:
requiredTypes - the requiredTypes
beanTypes - the beanTypes
Returns:
can we assign any type from requiredTypes to beanTypes

isAssignableFrom

public static boolean isAssignableFrom(Set<Type> types1,
                                       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 - the types1
type2 - the type2
Returns:
can we assign any type from types1 to type2

isAssignableFrom

public static boolean isAssignableFrom(Type[] types1,
                                       Type type2)

isSerializable

public static boolean isSerializable(Class<?> clazz)

isPrimitive

public static boolean isPrimitive(Type type)

getRawType

public static <T> Class<T> getRawType(Type type)

isClassLoadable

public static boolean isClassLoadable(String className,
                                      org.jboss.weld.resources.spi.ResourceLoader resourceLoader)


Copyright © 2013 Seam Framework. All Rights Reserved.