public static int moveAllTo(List<Config> configs, Map<String, String> oldToNewNames) {
    List<Config> configsToAdd = new ArrayList<>();
    List<Config> configsToRemove = new ArrayList<>();

    int numMoved = 0;
    for (Config config : configs) {
      final String oldName = config.getName();
      if (oldToNewNames.containsKey(oldName)) {
        configsToRemove.add(config);
        final Object value = config.getValue();
        final String newName = oldToNewNames.get(oldName);
        configsToAdd.add(new Config(newName, value));
        LOG.info(String.format(
            "Moving config value %s from old name %s to new name %s",
            value,
            oldName,
            newName
        ));
        numMoved++;
      }
    }
    configs.removeAll(configsToRemove);
    configs.addAll(configsToAdd);
    return numMoved;
  }
public static int moveAllTo(List<Config> configs, Map<String, String> oldToNewNames) {
    List<Config> configsToAdd = new ArrayList<>();
    List<Config> configsToRemove = new ArrayList<>();

    int numMoved = 0;
    for (Config config : configs) {
      final String oldName = config.getName();
      if (oldToNewNames.containsKey(oldName)) {
        configsToRemove.add(config);
        final Object value = config.getValue();
        final String newName = oldToNewNames.get(oldName);
        configsToAdd.add(new Config(newName, value));
        LOG.info(String.format(
            "Moving config value %s from old name %s to new name %s",
            value,
            oldName,
            newName
        ));
        numMoved++;
      }
    }
    configs.removeAll(configsToRemove);
    configs.addAll(configsToAdd);
    return numMoved;
  }
public static int moveAllTo ( List < Config > configs , Map < String , String > oldToNewNames ) { List < Config > configsToAdd = new ArrayList <> ( ) ; List < Config > configsToRemove = new ArrayList <> ( ) ; int numMoved = 0 ; for ( Config config : configs ) { final String oldName = config . getName ( ) ; if ( oldToNewNames . containsKey ( oldName ) ) { configsToRemove . add ( config ) ; final Object value = config . getValue ( ) ; final String newName = oldToNewNames . get ( oldName ) ; configsToAdd . add ( new Config ( newName , value ) ) ; LOG . info ( String . format ( "Moving config value %s from old name %s to new name %s" , value , oldName , newName ) ) ; numMoved ++ ; } } configs . removeAll ( configsToRemove ) ; configs . addAll ( configsToAdd ) ; return numMoved ; }
<p>
Move a series of config values from old names to new names (one to one correspondence).  Config values will be
preserved.
</p>

@param configs list of config objects (will be modified)
@param oldToNewNames a map of old to new config names
@return the number of config objects moved from old to new names
<p > Move a series of config values from old names to new names ( one to one correspondence ) . Config values will be preserved . < / p >