@Test public void testFromMap() { Map m = new HashMap() {{ put("A", 1); put("B", 2); put("C", 3); }}; Set s = Sets.fromMap(m, "A", "C"); assertTrue(s.contains(1)); assertFalse(s.contains(2)); assertTrue(s.contains(3)); assertEquals(2, s.size()); }
public static final Set fromMap(Map map, Object... keys) { if (keys != null && map != null) { Set answer = new HashSet(); for (Object key : keys) { if (map.containsKey(key)) { answer.add(map.get(key)); } } return Collections.unmodifiableSet(answer); } return Collections.EMPTY_SET; }
Sets { public static final Set fromMap(Map map, Object... keys) { if (keys != null && map != null) { Set answer = new HashSet(); for (Object key : keys) { if (map.containsKey(key)) { answer.add(map.get(key)); } } return Collections.unmodifiableSet(answer); } return Collections.EMPTY_SET; } }
Sets { public static final Set fromMap(Map map, Object... keys) { if (keys != null && map != null) { Set answer = new HashSet(); for (Object key : keys) { if (map.containsKey(key)) { answer.add(map.get(key)); } } return Collections.unmodifiableSet(answer); } return Collections.EMPTY_SET; }  }
Sets { public static final Set fromMap(Map map, Object... keys) { if (keys != null && map != null) { Set answer = new HashSet(); for (Object key : keys) { if (map.containsKey(key)) { answer.add(map.get(key)); } } return Collections.unmodifiableSet(answer); } return Collections.EMPTY_SET; }  static final Set fromMap(Map map, Object... keys); static final Set<String> fromCommaSeparatedValues(String csv); }
Sets { public static final Set fromMap(Map map, Object... keys) { if (keys != null && map != null) { Set answer = new HashSet(); for (Object key : keys) { if (map.containsKey(key)) { answer.add(map.get(key)); } } return Collections.unmodifiableSet(answer); } return Collections.EMPTY_SET; }  static final Set fromMap(Map map, Object... keys); static final Set<String> fromCommaSeparatedValues(String csv);  }