Last active
May 13, 2020 04:24
-
-
Save logbasex/9a71f43fdeed021698fa17c680659ac4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import static java.util.Objects.*; | |
public static String[] getNullProperties(Object source) { | |
final BeanWrapper wrappedSource = new BeanWrapperImpl(source); | |
return Stream.of(wrappedSource.getPropertyDescriptors()).map(FeatureDescriptor::getName) | |
.filter(propertyName -> isNull(wrappedSource.getPropertyValue(propertyName))).toArray(String[]::new); | |
} | |
//copy propreties that ignore null field in the request | |
BeanUtils.copyProperties(request, object, getNullProperties(request)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment