public final class ReflectionUtil extends Object
When a generic class is extended we often need to know which types were used to typify the generic.
Constructor and Description |
---|
ReflectionUtil() |
Modifier and Type | Method and Description |
---|---|
static void |
findGenericArgumentTypes(Object object) |
static void |
getBeanFromMap(CustomizableBeanWrapperFactory factory,
Map<String,Object> beanMap,
Object bean)
Fill up a java bean with the contents of a map where the keys are
property names.
|
static void |
getBeanFromMap(Map<String,Object> beanMap,
Object bean)
Fill up a java bean with the contents of a map where the keys are
property names.
|
static Class<?> |
getClass(Type type)
Get the underlying class for a type, or null if the type is a variable
type.
|
static Map<String,Object> |
getMapFromBean(CustomizableBeanWrapperFactory factory,
Object bean)
Transform a Java bean into a Map where the keys are the property names.
|
static Map<String,Object> |
getMapFromBean(Object bean)
Transform a Java bean into a Map where the keys are the property names.
|
static <T> List<Class<?>> |
getTypeArguments(Class<T> baseClass,
Class<? extends T> childClass)
Get the actual type arguments a child class has used to extend a generic
base class.
|
static <T> Map<TypeVariable<?>,Type> |
getTypeArgumentsMap(Class<T> baseClass,
Class<? extends T> childClass)
Get the type parameters and the corresponding actual type arguments a
child class has used to extend a generic base class.
|
static boolean |
isSimpleType(Type type)
Checks whether a type is a simple java type.
|
public static Class<?> getClass(Type type)
type
- the typepublic static <T> List<Class<?>> getTypeArguments(Class<T> baseClass, Class<? extends T> childClass)
T
- the generic typebaseClass
- the base classchildClass
- the child classpublic static <T> Map<TypeVariable<?>,Type> getTypeArgumentsMap(Class<T> baseClass, Class<? extends T> childClass)
T
- the generic typebaseClass
- the base classchildClass
- the child classpublic static void findGenericArgumentTypes(Object object)
public static boolean isSimpleType(Type type)
Simple java types are primitives, classes included in the "java" package, Interfaces and Enumerations. Simple java types cannot be java beans, so if this method returns true, you cannot create a BeanWrapper around the specified type.
type
- the type to testpublic static Map<String,Object> getMapFromBean(Object bean)
If there are nested beans, then the key will be the path of property
names in the form "prop1.prop2.prop2".
Properties with null values are not put in the map.
bean
- The bean to transformfor increased performance.
public static Map<String,Object> getMapFromBean(CustomizableBeanWrapperFactory factory, Object bean)
If there are nested beans, then the key will be the path of property
names in the form "prop1.prop2.prop2".
Properties with null values are not put in the map.
factory
- a BeanWrapperFactory instance to cache introspection
information. Increases performance if re-used.bean
- The bean to transformgetBeanFromMap(CustomizableBeanWrapperFactory, Map, Object)
public static void getBeanFromMap(Map<String,Object> beanMap, Object bean)
beanMap
- Map with property names and valuesbean
- bean instance to fill upfor
increased performance.
public static void getBeanFromMap(CustomizableBeanWrapperFactory factory, Map<String,Object> beanMap, Object bean)
factory
- a BeanWrapperFactory instance to cache introspection
information. Increases performance if re-used.beanMap
- Map with property names and valuesbean
- bean instance to fill upCopyright © 2011–2020 Juffrou. All rights reserved.