commons-beanutils icon indicating copy to clipboard operation
commons-beanutils copied to clipboard

create method copyNonNullProperties

Open XiongDWM opened this issue 1 year ago • 2 comments

When updating an entity, only a subset of properties may be provided (e.g., For a person entity[name: String, age: Integer, gender: boolean, address: String] while only the name and age are provided, or says we only want to update person's name and age, and other properties like gender or address are null). In such cases, copying all properties including null values will overwrite the existing values in the target object, which is not desirable, some would say we can use setters to set the changing properties to the origin entity, but what if 10 properties need to change? This feature will prevent null values from overwriting existing values in the target object, ensuring that only the provided properties are updated without coding too much by use setter.

XiongDWM avatar Nov 14 '24 08:11 XiongDWM

how about expand method doesn't copy empty properties as well

F0otman avatar Nov 20 '24 03:11 F0otman

how about expand method doesn't copy empty properties as well

you mean properties like empty string or empty collection? sure tho

XiongDWM avatar Nov 22 '24 08:11 XiongDWM