sf logo

sf.qof.util
Class ReflectionUtils

java.lang.Object
  extended by sf.qof.util.ReflectionUtils

public final class ReflectionUtils
extends Object

Utility class for reflection functionality.


Method Summary
static Class<?> box(Class<?> type)
          Returns the boxed type of a specified primitive type.
static Method findGetter(Class<?> type, String fieldName)
          Returns the getter method for a field name in a specified class.
static Method findSetter(Class<?> type, String fieldName)
          Returns the setter method for a field name in a specified class.
static Method findSetter(Class<?> type, String fieldName, Set<Class<?>> mappableTypes)
          Returns the setter method for a field name in a specified class that uses a parameter of a type in a set.
static Class<?> getArrayComponentType(Type type)
          Returns the array component type of a type.
static Class<?> getCollectionParameterizedKeyType(Type type)
          Returns the key type of a parameterized type.
static Class<?> getCollectionParameterizedType(Type type)
          Returns the parameterized type of a collection type.
static Class<?> getCollectionType(Type type)
          Returns the collection or map type of a type.
static net.sf.cglib.core.Signature getConstructorSignature(Constructor<?> constructor)
          Returns a constructor Signature object for a Constructor parameter.
static net.sf.cglib.core.Signature getMethodSignature(Method method)
          Returns a method Signature object for a Method parameter.
static Class<?> unbox(Class<?> type)
          Returns the unboxed type of a specified type.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

findGetter

public static Method findGetter(Class<?> type,
                                String fieldName)
Returns the getter method for a field name in a specified class.

Parameters:
type - the class
fieldName - field name
Returns:
getter method for a field or null

findSetter

public static Method findSetter(Class<?> type,
                                String fieldName)
Returns the setter method for a field name in a specified class.

Parameters:
type - the class
fieldName - field name
Returns:
setter method for a field or null

findSetter

public static Method findSetter(Class<?> type,
                                String fieldName,
                                Set<Class<?>> mappableTypes)
Returns the setter method for a field name in a specified class that uses a parameter of a type in a set.

Parameters:
type - the class
fieldName - field name
mappableTypes - set of all mappable types
Returns:
setter method for a field or null

getCollectionType

public static Class<?> getCollectionType(Type type)
Returns the collection or map type of a type.

Parameters:
type - the type
Returns:
the collection type or null

getArrayComponentType

public static Class<?> getArrayComponentType(Type type)
Returns the array component type of a type.

Parameters:
type - the type
Returns:
the array component type or null

getCollectionParameterizedType

public static Class<?> getCollectionParameterizedType(Type type)
Returns the parameterized type of a collection type. For example if type is List<String> this method returns String. If type is Map<int, String> it returns String.

Parameters:
type - the parameterized type
Returns:
the parameterized type
Throws:
ValidationException - if type is not parameterized

getCollectionParameterizedKeyType

public static Class<?> getCollectionParameterizedKeyType(Type type)
Returns the key type of a parameterized type. For example if type is Map<int, String> it returns int.

Parameters:
type - the parameterized type
Returns:
the key type

unbox

public static Class<?> unbox(Class<?> type)
Returns the unboxed type of a specified type. Types that are not boxed are returned unchanged.

Parameters:
type - the type
Returns:
unboxed type

box

public static Class<?> box(Class<?> type)
Returns the boxed type of a specified primitive type. Types that are not primitive types are returned unchanged.

Parameters:
type - the type
Returns:
boxed type

getMethodSignature

public static net.sf.cglib.core.Signature getMethodSignature(Method method)
Returns a method Signature object for a Method parameter.

Parameters:
method - the method
Returns:
a method signature

getConstructorSignature

public static net.sf.cglib.core.Signature getConstructorSignature(Constructor<?> constructor)
Returns a constructor Signature object for a Constructor parameter.

Parameters:
constructor - the constructor
Returns:
a constructor signature

sf logo

Copyright © 2007 brunella ltd. All Rights Reserved.