Eko Kurniawan Khannedy opened SPR-15581 and commented

This is jira for pull request : https://github.com/spring-projects/spring-framework/pull/1431

In my project, I have some ugly code to merge 2 properties object like this

Configuration global = appContext.getBean("globalConfig", Configuration.class);
Configuration config = appContext.getBean("configName", Configuration.class);

Configuration mergeConfig = new Configuration()
BeanUtils.copyProperties(mergeConfig, global);

if(config.getFoo() != null){
   mergeConfig.setFoo(config.getFoo());
}

if(config.getBar() != null){
   mergeConfig.setBar(config.getBar());
}

if(config.getXxx() != null){
   mergeConfig.setXxx(config.getXxx());
}

My code only make sure that I only override non null values. This is very ugly because I need to check null in all of attributes.

This pull request is to add Predicate support for BeanUtils.copyProperties, so I can merge properties easily.

Configuration global = appContext.getBean("globalConfig", Configuration.class);
Configuration config = appContext.getBean("configName", Configuration.class);

Configuration mergeConfig = new Configuration();
BeanProperties.copyProperties(mergeConfig, global);
BeanProperties.copyProperties(mergeConfig, config, Objects::nonNull)

Referenced from: pull request https://github.com/spring-projects/spring-framework/pull/1431

Comment From: snicoll

Closing as a result of https://github.com/spring-projects/spring-framework/pull/1431#issuecomment-977936077