Java Map Remove removeAllNullValueEntry(Map source)

Here you can find the source of removeAllNullValueEntry(Map source)

Description

remove All Null Value Entry

License

Apache License

Declaration

public static <R, T> Map<R, T> removeAllNullValueEntry(Map<R, T> source) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.util.HashMap;

import java.util.Map;

import java.util.Map.Entry;

public class Main {

    public static <R, T> Map<R, T> removeAllNullValueEntry(Map<R, T> source) {
        if (null == source) {
            return new HashMap<R, T>();
        }//w  ww . j  av  a 2  s  . co m
        Map<R, T> map = new HashMap<R, T>();
        for (Entry<R, T> entry : source.entrySet()) {
            if (null == entry.getValue() || null == entry.getKey()) {
                continue;
            }
            map.put(entry.getKey(), entry.getValue());
        }
        return map;
    }
}

Related

  1. remove(Map map, Collection keys)
  2. remove(Map map, K key)
  3. removeAll(final Map target, final Iterable keys, Collection values)
  4. removeAll(Map map, Set keys)
  5. removeAllFromCollection(Map> map, Object key, Collection values)
  6. removeAndCleanFromCollectionMap(KeyT key, ValT toBeRemoved, Map> map)
  7. removeApiUuidMap(String apiName)
  8. removeClassFromMap(final Map the_map, final String the_class_name)
  9. removeColor(Map windowColorCountMap, int windowColorCount, int lastColor)