Skip to content

Commit

Permalink
Rename variable to be more descriptive
Browse files Browse the repository at this point in the history
  • Loading branch information
klaren committed Feb 22, 2018
1 parent 8b8df78 commit 412b8d3
Showing 1 changed file with 13 additions and 8 deletions.
Expand Up @@ -596,8 +596,8 @@ public void updateDynamicSetting( String setting, String update )


synchronized ( params ) synchronized ( params )
{ {
boolean oldDefault = false; boolean oldValueIsDefault = false;
boolean newDefault = false; boolean newValueIsDefault = false;
String oldValue; String oldValue;
String newValue; String newValue;
if ( update == null || update.isEmpty() ) if ( update == null || update.isEmpty() )
Expand All @@ -607,7 +607,7 @@ public void updateDynamicSetting( String setting, String update )
boolean hasDefault = overriddenDefault != null; boolean hasDefault = overriddenDefault != null;
oldValue = hasDefault ? params.put( setting, overriddenDefault ) : params.remove( setting ); oldValue = hasDefault ? params.put( setting, overriddenDefault ) : params.remove( setting );
newValue = getDefaultValueOf( setting ); newValue = getDefaultValueOf( setting );
newDefault = true; newValueIsDefault = true;
} }
else else
{ {
Expand All @@ -621,16 +621,21 @@ public void updateDynamicSetting( String setting, String update )
validator.validate( newEntry, ignore -> {} ); // Throws if invalid validator.validate( newEntry, ignore -> {} ); // Throws if invalid
} }


oldValue = getDefaultValueOf( setting ); String previousValue = params.put( setting, update );
if ( params.put( setting, update ) == null ) if ( previousValue != null )
{ {
oldDefault = true; oldValue = previousValue;
}
else
{
oldValue = getDefaultValueOf( setting );
oldValueIsDefault = true;
} }
newValue = update; newValue = update;
} }
log.info( "Setting changed: '%s' changed from '%s' to '%s'", log.info( "Setting changed: '%s' changed from '%s' to '%s'",
setting, oldDefault ? "default (" + oldValue + ")" : oldValue, setting, oldValueIsDefault ? "default (" + oldValue + ")" : oldValue,
newDefault ? "default (" + newValue + ")" : newValue ); newValueIsDefault ? "default (" + newValue + ")" : newValue );
updateListeners.getOrDefault( setting, emptyList() ).forEach( l -> l.accept( oldValue, newValue ) ); updateListeners.getOrDefault( setting, emptyList() ).forEach( l -> l.accept( oldValue, newValue ) );
} }
} }
Expand Down

0 comments on commit 412b8d3

Please sign in to comment.