create method copyNonNullProperties #314
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.