org.hibersap.mapping
Class ReflectionHelper

java.lang.Object
  extended by org.hibersap.mapping.ReflectionHelper

public final class ReflectionHelper
extends Object

Author:
Carsten Erker

Method Summary
static
<T> List<T>
createInstances(List<String> fullyQualifiedClassNames, Class<T> superType)
           
static Class<?> getArrayType(Class<?> type)
          Get the array type of type, or null if type is not an array.
static Class<?> getClassForName(String className)
           
static Field getDeclaredField(Object bean, String fieldName)
           
static Set<Field> getDeclaredFieldsWithAnnotationRecursively(Class<?> clazz, Class<? extends Annotation> annotationClass)
           
static Object getFieldValue(Object bean, String fieldName)
           
static Class<?> getGenericType(Field field)
          Get the actual type of a one-dimensional generic field.
static
<T> T[]
newArrayFromCollection(Collection<?> collection, Class<T> elementType)
           
static Collection<Object> newCollectionInstance(Class<? extends Collection> clazz)
           
static
<T> T
newInstance(Class<T> clazz)
           
static
<T> T
newInstance(String fullyQualifiedClassName, Class<T> superType)
           
static void setFieldValue(Object bean, String fieldName, Object value)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getClassForName

public static Class<?> getClassForName(String className)
                                throws ClassNotFoundException
Throws:
ClassNotFoundException

getArrayType

public static Class<?> getArrayType(Class<?> type)
Get the array type of type, or null if type is not an array.

Parameters:
type - The array class type.
Returns:
The type of the array components.

getDeclaredField

public static Field getDeclaredField(Object bean,
                                     String fieldName)

getFieldValue

public static Object getFieldValue(Object bean,
                                   String fieldName)

getGenericType

public static Class<?> getGenericType(Field field)
Get the actual type of a one-dimensional generic field.

Parameters:
field - The field
Returns:
The generic type or null if the field is not generic

newCollectionInstance

public static Collection<Object> newCollectionInstance(Class<? extends Collection> clazz)

newInstance

public static <T> T newInstance(Class<T> clazz)

newInstance

public static <T> T newInstance(String fullyQualifiedClassName,
                                Class<T> superType)

createInstances

public static <T> List<T> createInstances(List<String> fullyQualifiedClassNames,
                                          Class<T> superType)

setFieldValue

public static void setFieldValue(Object bean,
                                 String fieldName,
                                 Object value)

getDeclaredFieldsWithAnnotationRecursively

public static Set<Field> getDeclaredFieldsWithAnnotationRecursively(Class<?> clazz,
                                                                    Class<? extends Annotation> annotationClass)

newArrayFromCollection

public static <T> T[] newArrayFromCollection(Collection<?> collection,
                                             Class<T> elementType)


Copyright © 2012 akquinet tech@spree GmbH. All Rights Reserved.