void addOrChangeProperty ( final String name , final Object newValue , final Configuration config ) { // We do not want to abort the operation due to failed validation on one property try { if ( ! config . containsKey ( name ) ) { logger . debug ( "adding property key [{}], value [{}]" , name , newValue ) ; config . addProperty ( name , newValue ) ; } else { Object oldValue = config . getProperty ( name ) ; if ( newValue != null ) { Object newValueArray ; if ( oldValue instanceof CopyOnWriteArrayList && AbstractConfiguration . getDefaultListDelimiter ( ) != ' ' ) { newValueArray = new CopyOnWriteArrayList ( ) ; Iterable < String > stringiterator = Splitter . on ( AbstractConfiguration . getDefaultListDelimiter ( ) ) . omitEmptyStrings ( ) . trimResults ( ) . split ( ( String ) newValue ) ; for ( String s : stringiterator ) { ( ( CopyOnWriteArrayList ) newValueArray ) . add ( s ) ; } } else { newValueArray = newValue ; } if ( ! newValueArray . equals ( oldValue ) ) { logger . debug ( "updating property key [{}], value [{}]" , name , newValue ) ; config . setProperty ( name , newValue ) ; } } else if ( oldValue != null ) { logger . debug ( "nulling out property key [{}]" , name ) ; config . setProperty ( name , null ) ; } } } catch ( ValidationException e ) { logger . warn ( "Validation failed for property " + name , e ) ; } }
Add or update the property in the underlying config depending on if it exists