@Test public void keys() { Set<String> keys0 = ValueOptionMap.keys(); assertThat(keys0, hasSize(0)); Set<String> keys1 = ValueOptionMap.keys("a"); assertThat(keys1, contains("a")); Set<String> keysN = ValueOptionMap.keys("a", "b", "c", "d", "e"); assertThat(keysN, contains("a", "b", "c", "d", "e")); }
@SafeVarargs public static <T> Set<T> keys(T... keys) { if (keys.length == 0) { return Collections.emptySet(); } else if (keys.length == 1) { return Collections.singleton(keys[0]); } else { Set<T> results = new LinkedHashSet<>(keys.length * 2); Collections.addAll(results, keys); return Collections.unmodifiableSet(results); } }
ValueOptionMap extends AbstractMap<K, V> { @SafeVarargs public static <T> Set<T> keys(T... keys) { if (keys.length == 0) { return Collections.emptySet(); } else if (keys.length == 1) { return Collections.singleton(keys[0]); } else { Set<T> results = new LinkedHashSet<>(keys.length * 2); Collections.addAll(results, keys); return Collections.unmodifiableSet(results); } } }
ValueOptionMap extends AbstractMap<K, V> { @SafeVarargs public static <T> Set<T> keys(T... keys) { if (keys.length == 0) { return Collections.emptySet(); } else if (keys.length == 1) { return Collections.singleton(keys[0]); } else { Set<T> results = new LinkedHashSet<>(keys.length * 2); Collections.addAll(results, keys); return Collections.unmodifiableSet(results); } }  }
ValueOptionMap extends AbstractMap<K, V> { @SafeVarargs public static <T> Set<T> keys(T... keys) { if (keys.length == 0) { return Collections.emptySet(); } else if (keys.length == 1) { return Collections.singleton(keys[0]); } else { Set<T> results = new LinkedHashSet<>(keys.length * 2); Collections.addAll(results, keys); return Collections.unmodifiableSet(results); } }  @SafeVarargs static Set<T> keys(T... keys); @Override abstract V get(Object key); @Override V put(K key, V value); @Override abstract Set<K> keySet(); @Override boolean containsKey(Object key); @Override Set<Map.Entry<K, V>> entrySet(); @Override int size(); @Override void forEach(BiConsumer<? super K, ? super V> action); }
ValueOptionMap extends AbstractMap<K, V> { @SafeVarargs public static <T> Set<T> keys(T... keys) { if (keys.length == 0) { return Collections.emptySet(); } else if (keys.length == 1) { return Collections.singleton(keys[0]); } else { Set<T> results = new LinkedHashSet<>(keys.length * 2); Collections.addAll(results, keys); return Collections.unmodifiableSet(results); } }  @SafeVarargs static Set<T> keys(T... keys); @Override abstract V get(Object key); @Override V put(K key, V value); @Override abstract Set<K> keySet(); @Override boolean containsKey(Object key); @Override Set<Map.Entry<K, V>> entrySet(); @Override int size(); @Override void forEach(BiConsumer<? super K, ? super V> action);  }