public final class BeanUtils extends Object
BeanUtils| Modifier and Type | Method and Description |
|---|---|
static void |
copyProperties(Object source,
Object target)
Copy the property values of the given source bean into the target bean.
|
static void |
copyProperties(Object source,
Object target,
Class<?> editable)
Copy the property values of the given source bean into the given target bean,
only setting properties defined in the given "editable" class (or interface).
|
static void |
copyProperties(Object source,
Object target,
String... ignoreProperties)
Copy the property values of the given source bean into the given target bean,
ignoring the given "ignoreProperties".
|
public static void copyProperties(Object source, Object target) throws org.springframework.beans.BeansException
Note: The source and target classes do not have to match or even be derived from each other, as long as the properties match. Any bean properties that the source bean exposes but the target bean does not will silently be ignored.
This is just a convenience method. For more complex transfer needs, consider using a full BeanWrapper.
source - the source beantarget - the target beanorg.springframework.beans.BeansException - if the copying failedBeanWrapperpublic static void copyProperties(Object source, Object target, Class<?> editable) throws org.springframework.beans.BeansException
Note: The source and target classes do not have to match or even be derived from each other, as long as the properties match. Any bean properties that the source bean exposes but the target bean does not will silently be ignored.
This is just a convenience method. For more complex transfer needs, consider using a full BeanWrapper.
source - the source beantarget - the target beaneditable - the class (or interface) to restrict property setting toorg.springframework.beans.BeansException - if the copying failedBeanWrapperpublic static void copyProperties(Object source, Object target, String... ignoreProperties) throws org.springframework.beans.BeansException
Note: The source and target classes do not have to match or even be derived from each other, as long as the properties match. Any bean properties that the source bean exposes but the target bean does not will silently be ignored.
This is just a convenience method. For more complex transfer needs, consider using a full BeanWrapper.
source - the source beantarget - the target beanignoreProperties - array of property names to ignoreorg.springframework.beans.BeansException - if the copying failedBeanWrapperCopyright © 2010–2018 The Apache Software Foundation. All rights reserved.