|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectorg.springframework.beans.BeanUtils
Static convenience methods for JavaBeans, for instantiating beans, copying bean properties, etc.
Mainly for use within the framework, but to some degree also useful for application classes.
| Constructor Summary | |
BeanUtils()
|
|
| Method Summary | |
static void |
copyProperties(java.lang.Object source,
java.lang.Object target)
Copy the property values of the given source bean into the target bean. |
static void |
copyProperties(java.lang.Object source,
java.lang.Object target,
java.lang.String[] ignoreProperties)
Copy the property values of the given source bean into the given target bean, ignoring the given ignoreProperties. |
static java.lang.reflect.Method |
findDeclaredMethod(java.lang.Class clazz,
java.lang.String methodName,
java.lang.Class[] paramTypes)
Find a method with the given method name and the given parameter types, declared on the given class or one of its superclasses. |
static java.lang.reflect.Method |
findDeclaredMethodWithMinimalParameters(java.lang.Class clazz,
java.lang.String methodName)
Find a method with the given method name and minimal parameters (best case: none), declared on the given class or one of its superclasses. |
static java.lang.reflect.Method |
findMethod(java.lang.Class clazz,
java.lang.String methodName,
java.lang.Class[] paramTypes)
Find a method with the given method name and the given parameter types, declared on the given class or one of its superclasses. |
static java.lang.reflect.Method |
findMethodWithMinimalParameters(java.lang.Class clazz,
java.lang.String methodName)
Find a method with the given method name and minimal parameters (best case: none), declared on the given class or one of its superclasses. |
static java.lang.Object |
instantiateClass(java.lang.Class clazz)
Convenience method to instantiate a class using its no-arg constructor. |
static java.lang.Object |
instantiateClass(java.lang.reflect.Constructor ctor,
java.lang.Object[] args)
Convenience method to instantiate a class using the given constructor. |
static boolean |
isAssignable(java.lang.Class targetType,
java.lang.Class valueType)
Determine if the given target type is assignable from the given value type, assuming setting by reflection. |
static boolean |
isAssignable(java.lang.Class type,
java.lang.Object value)
Determine if the given type is assignable from the given value, assuming setting by reflection. |
static boolean |
isPrimitiveArray(java.lang.Class clazz)
Check if the given class represents a primitive array, i.e. boolean, byte, char, short, int, long, float, or double. |
static boolean |
isPrimitiveWrapperArray(java.lang.Class clazz)
Check if the given class represents an array of primitive wrappers, i.e. |
static boolean |
isSimpleProperty(java.lang.Class clazz)
Check if the given class represents a "simple" property, i.e. a primitive, a String, a Class, or a corresponding array. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
public BeanUtils()
| Method Detail |
public static java.lang.Object instantiateClass(java.lang.Class clazz)
throws BeansException
Note that this method tries to set the constructor accessible if given a non-accessible (i.e. non-public) constructor.
clazz - class to instantiate
BeansException
public static java.lang.Object instantiateClass(java.lang.reflect.Constructor ctor,
java.lang.Object[] args)
throws BeansException
Note that this method tries to set the constructor accessible if given a non-accessible (i.e. non-public) constructor.
ctor - constructor to instantiate
BeansException
public static java.lang.reflect.Method findMethod(java.lang.Class clazz,
java.lang.String methodName,
java.lang.Class[] paramTypes)
Checks Class.getMethod first, falling back to
findDeclaredMethod. This allows to find public methods
without issues even in environments with restricted Java security settings.
clazz - the class to checkmethodName - the name of the method to findparamTypes - the parameter types of the method to find
Class.getMethod(java.lang.String, java.lang.Class[]),
findDeclaredMethod(java.lang.Class, java.lang.String, java.lang.Class[])
public static java.lang.reflect.Method findDeclaredMethod(java.lang.Class clazz,
java.lang.String methodName,
java.lang.Class[] paramTypes)
Checks Class.getDeclaredMethod, cascading upwards to all superclasses.
clazz - the class to checkmethodName - the name of the method to findparamTypes - the parameter types of the method to find
Class.getDeclaredMethod(java.lang.String, java.lang.Class[])
public static java.lang.reflect.Method findMethodWithMinimalParameters(java.lang.Class clazz,
java.lang.String methodName)
Checks Class.getMethods first, falling back to
findDeclaredMethodWithMinimalParameters. This allows to find public
methods without issues even in environments with restricted Java security settings.
clazz - the class to checkmethodName - the name of the method to find
Class.getMethods(),
findDeclaredMethodWithMinimalParameters(java.lang.Class, java.lang.String)
public static java.lang.reflect.Method findDeclaredMethodWithMinimalParameters(java.lang.Class clazz,
java.lang.String methodName)
Checks Class.getDeclaredMethods, cascading upwards to all superclasses.
clazz - the class to checkmethodName - the name of the method to find
Class.getDeclaredMethods()
public static boolean isAssignable(java.lang.Class type,
java.lang.Object value)
For example used in a bean factory's constructor resolution.
type - the target typevalue - the value that should be assigned to the type
public static boolean isAssignable(java.lang.Class targetType,
java.lang.Class valueType)
For example used in BeanWrapperImpl's custom editor matrching.
targetType - the target typevalueType - the value type that should be assigned to the target type
public static boolean isSimpleProperty(java.lang.Class clazz)
AbstractBeanDefinition.DEPENDENCY_CHECK_SIMPLE,
AbstractAutowireCapableBeanFactory.dependencyCheck(java.lang.String, org.springframework.beans.factory.support.RootBeanDefinition, org.springframework.beans.BeanWrapper, org.springframework.beans.PropertyValues)public static boolean isPrimitiveArray(java.lang.Class clazz)
public static boolean isPrimitiveWrapperArray(java.lang.Class clazz)
public static void copyProperties(java.lang.Object source,
java.lang.Object target)
throws java.lang.IllegalArgumentException,
BeansException
source - source beantarget - target bean
java.lang.IllegalArgumentException - if the classes of source and target do not match
BeansException
public static void copyProperties(java.lang.Object source,
java.lang.Object target,
java.lang.String[] ignoreProperties)
throws java.lang.IllegalArgumentException,
BeansException
source - source beantarget - target beanignoreProperties - array of property names to ignore
java.lang.IllegalArgumentException - if the classes of source and target do not match
BeansException
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||