public final class ReflectUtils extends Object
Modifier and Type | Method and Description |
---|---|
static PropertyDescriptor |
getPropertyDescriptor(BeanInfo info,
String propertyName)
Gets the property descriptor for the named property from the bean info describing
a particular class to which property belongs.
|
static PropertyDescriptor |
getPropertyDescriptor(Class<?> clazz,
String propertyName)
Gets the property descriptor for the named property on the given class.
|
static <T> Class<T> |
loadClass(String className)
Attempts to create a class from a String.
|
static <T> T |
newInstance(Class<T> clazz,
Object... args)
Creates a new instance of the given class by passing the given arguments
to the constructor.
|
static <T> T |
newInstance(String className,
Object... args)
Creates a new instance of the given class by passing the given arguments
to the constructor.
|
static void |
setProperty(String propertyName,
Object value,
Object target)
Sets the given property on the target JavaBean using bean instrospection.
|
static void |
setProperty(String propertyName,
Object value,
Object target,
BeanInfo info)
Sets the given property on the target JavaBean using bean instrospection.
|
public static <T> Class<T> loadClass(String className) throws IllegalArgumentException
className
- the name of the class to create.IllegalArgumentException
- if the className does not exist.public static <T> T newInstance(String className, Object... args)
className
- Name of class to be created.args
- Constructor arguments.public static <T> T newInstance(Class<T> clazz, Object... args)
clazz
- Class of instance to be created.args
- Constructor arguments.public static PropertyDescriptor getPropertyDescriptor(Class<?> clazz, String propertyName)
clazz
- Class to which property belongs.propertyName
- Name of property.public static PropertyDescriptor getPropertyDescriptor(BeanInfo info, String propertyName)
info
- Bean info describing class to which property belongs.propertyName
- Name of property.public static void setProperty(String propertyName, Object value, Object target)
propertyName
- Property to set.value
- Property value to set.target
- Target java bean on which to set property.public static void setProperty(String propertyName, Object value, Object target, BeanInfo info)
propertyName
- Property to set.value
- Property value to set.target
- Target JavaBean on which to set property.info
- BeanInfo describing the target JavaBean.Copyright © 2006–2018 Jasig. All rights reserved.