spring-framework / org.springframework.beans / BeanUtils / copyProperties

copyProperties

open static fun copyProperties(source: Any, target: Any): Unit

Copy the property values of the given source bean into the target bean.

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.

Parameters

source - the source bean

target - the target bean

Exceptions

BeansException - if the copying failed

See Also
BeanWrapper

open static fun copyProperties(source: Any, target: Any, editable: Class<*>): Unit

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).

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.

Parameters

source - the source bean

target - the target bean

editable - the class (or interface) to restrict property setting to

Exceptions

BeansException - if the copying failed

See Also
BeanWrapper

open static fun copyProperties(source: Any, target: Any, vararg ignoreProperties: String): Unit

Copy the property values of the given source bean into the given target bean, ignoring the given "ignoreProperties".

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.

Parameters

source - the source bean

target - the target bean

ignoreProperties - array of property names to ignore

Exceptions

BeansException - if the copying failed

See Also
BeanWrapper