Java Map Remove removeNullPair(Map map)

Here you can find the source of removeNullPair(Map map)

Description

remove Null Pair

License

Open Source License

Declaration

public static void removeNullPair(Map map) 

Method Source Code

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

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

public class Main {
    public static void removeNullPair(Map map) {
        List<Object> nullPairKeyList = new ArrayList<>();
        for (Object key : map.keySet()) {
            if ("".equals(key) || map.get(key) == null) {
                nullPairKeyList.add(key);
            }/*from w  w w  .  jav  a 2  s  .  c  o  m*/
        }
        for (Object nullPairKey : nullPairKeyList) {
            map.remove(nullPairKey);
        }
    }
}

Related

  1. removeKeysWithPrefix(Map map, String prefix)
  2. removeMapEntryFromPreferenceStoredMap(String keyOfPreference, String keyInMap)
  3. removeNamespaces(Map properties)
  4. removeNode(Map map, List pathItems)
  5. removeNullEntries(Map map)
  6. removeNullValues(final Map parameters)
  7. removeNullValues(Map map)
  8. removeObject(Map map, T key)
  9. removeObjectProperty(Map properties, String key, Object defaultValue)