Java Map Replace replaceKey(final Map map, final TKey oldkey, final TKey newkey)

Here you can find the source of replaceKey(final Map map, final TKey oldkey, final TKey newkey)

Description

replace Key

License

Open Source License

Declaration

public static <TKey, TValue> void replaceKey(final Map<TKey, TValue> map, final TKey oldkey, final TKey newkey)
            throws IllegalArgumentException 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import java.util.Map;

public class Main {
    public static <TKey, TValue> void replaceKey(final Map<TKey, TValue> map, final TKey oldkey, final TKey newkey)
            throws IllegalArgumentException {
        if (map != null && map.containsKey(oldkey)) {
            map.put(newkey, map.get(oldkey));

        } else {/*from w w  w.j  a  v  a  2s  .co m*/
            throw new IllegalArgumentException("Map must be effective and contain the old key.");
        }
    }
}

Related

  1. replaceEntities(final Map replacements, final String xml)
  2. replaceFromMap(final String string, final Map replacements)
  3. replaceFromMap(String string, Map replacements)
  4. replaceGlobalTokensFromMap(Map dataMap, String message)
  5. replaceInvalid(String uri, Map reps)
  6. replaceKey(Map map, K oldKey, K newKey)
  7. replaceKeyCharacter(Map map, char oldChar, char newChar)
  8. replaceKeyword(String messageTemplate, Map args, String key)
  9. replaceMap(String inStr, Map replaceMap)