Here you can find the source of copyExcludingKeys(Map
Parameter | Description |
---|---|
map | a parameter |
excludedKeys | a parameter |
public static <K, V> Map<K, V> copyExcludingKeys(Map<K, V> map, Set<K> excludedKeys)
//package com.java2s; //License from project: Open Source License import java.util.HashMap; import java.util.Map; import java.util.Map.Entry; import java.util.Set; public class Main { /**//from w w w. j a v a 2s. co m * Returns new Map * * @param map * @param excludedKeys * @return */ public static <K, V> Map<K, V> copyExcludingKeys(Map<K, V> map, Set<K> excludedKeys) { Map<K, V> resultMap = new HashMap<>(); for (Entry<K, V> entry : map.entrySet()) { if (false == excludedKeys.contains(entry.getKey())) { resultMap.put(entry.getKey(), entry.getValue()); } } return resultMap; } }