PatternUtil { public static <K, V> Map<K, V> createExtractedMap(Map<K, V> map, Set<K> keys) { Map<K, V> retValue = new LinkedHashMap<K, V>(); for (K key : keys) { retValue.put(key, map.get(key)); } return retValue; } private  PatternUtil(); static Definition replacePlaceholders(Definition d, String name,
            Object... varsOrig); static Map<K, V> createExtractedMap(Map<K, V> map, Set<K> keys);  }
@Test public void testCreateExtractedMap() { Map<Integer, String> map = new HashMap<Integer, String>(); map.put(0, "value0"); map.put(1, "value1"); map.put(2, "value2"); Set<Integer> set = new HashSet<Integer>(); set.add(1); set.add(2); Map<Integer, String> extractedMap = PatternUtil.createExtractedMap(map, set); assertEquals(2, extractedMap.size()); assertEquals("value1", extractedMap.get(1)); assertEquals("value2", extractedMap.get(2)); }