CollectionsExt { @SafeVarargs public static <T> boolean containsAnyKeys(Map<T, ?> map, T... keys) { if (map == null) { return false; } for (T key : keys) { if (map.containsKey(key)) { return true; } } return false; } private  CollectionsExt(); static boolean isNullOrEmpty(Map<K, V> map); static boolean isNullOrEmpty(Collection<T> collection); static boolean isNullOrEmpty(T[] array); static void ifNotEmpty(C collection, Runnable runnable); static void applyNotEmpty(C collection, Consumer<C> consumer); static List<T> nonNull(List<T> collection); static Set<T> nonNull(Set<T> collection); static Map<K, V> nonNull(Map<K, V> map); static T first(Collection<T> collection); static T firstOrDefault(Collection<T> collection, T defaultValue); static T last(List<T> list); static T last(Stream<T> stream); static T getOrDefault(T[] array, int idx, T defaultValue); static void addAll(Collection<T> target, T[] source); static List<T> asList(T[] source, int from); static List<T> asList(T[] source, int from, int to); static Set<T> take(Set<T> collection, int count); static C copy(C source, C destination, int count); static List<T> copyAndAdd(List<T> original, T newItem); static List<T> copyAndAddToList(Collection<T> original, T newItem); static Set<T> copyAndAdd(Set<T> original, T newItem); static Map<K, V> copyAndAdd(Map<K, V> original, K key, V value); static Map<K, V> copyAndAdd(Map<K, V> original, Map<K, V> additions); static List<T> nullableImmutableCopyOf(List<T> original); static List<T> nonNullImmutableCopyOf(List<T> original); static Map<K, V> nullableImmutableCopyOf(Map<K, V> original); static List<T> copyAndRemove(List<T> original, Predicate<T> removePredicate); static Set<T> copyAndRemove(Set<T> original, T toRemove); static Set<T> copyAndRemove(Set<T> original, Collection<T> toRemove); static Map<K, V> copyAndRemove(Map<K, V> original, K... keys); static Map<K, V> copyAndRemove(Map<K, V> original, Collection<K> keys); static Map<K, V> copyAndRemoveByKey(Map<K, V> original, Predicate<K> keysPredicate); static Map<K, V> copyAndRemoveByValue(Map<K, V> original, Predicate<V> removePredicate); static List<V> multiMapAddValue(Map<K, List<V>> multiMap, K key, V value); @SafeVarargs static List<T> merge(List<T>... lists); @SafeVarargs static Set<T> merge(Set<T>... sets); @SafeVarargs static Set<T> merge(Supplier<Set<T>> supplier, Set<T>... sets); @SafeVarargs static Map<K, V> merge(Map<K, V>... maps); static Map<K, V> merge(Map<K, V> first, Map<K, V> second, BiFunction<V, V, V> conflictFunction); static Map<K, V> mapValues(Map<K, U> source, Function<U, V> valueMapper, Supplier<Map<K, V>> mapSupplier); static Map<K, V> mapValuesWithKeys(Map<K, U> source, BiFunction<K, U, V> valueMapper, Supplier<Map<K, V>> mapSupplier); static Set<T> xor(Set<T>... sets); static Pair<List<T>, List<T>> split(List<T> items, Predicate<T> predicate); static Set<R> transformSet(Set<T> source, Function<T, R> transformer); static Map<K, R> transformValues(Map<K, V> source, Function<V, R> transformer); @SafeVarargs static Set<T> asSet(T... values); static Set<T> asSet(T[] values, int from, int to); @SafeVarargs static Map<T, T> asMap(T... values); static Map<K, V> zipToMap(Collection<K> keys, Collection<V> values); static MapBuilder<K, V> newMap(Supplier<Map<K, V>> mapTypeBuilder); static MapBuilder<K, V> newHashMap(); static MapBuilder<K, V> newHashMap(Map<K, V> original); static Map<K, V> newMapFrom(K[] keys, Function<K, V> valueFun); static int[] toPrimitiveArray(Collection<Integer> collection); static char[] toPrimitiveCharArray(Collection<Character> collection); static char[] toPrimitiveCharArray(Character[] arrayOfChar); static List<Integer> toWrapperList(int[] intArray); static List<List<T>> chop(List<T> list, int chunkSize); static Optional<C> optionalOfNotEmpty(C collection); @SafeVarargs static boolean containsKeys(Map<T, ?> map, T... keys); @SafeVarargs static boolean containsAnyKeys(Map<T, ?> map, T... keys); static Map<I, T> indexBy(List<T> items, Function<T, I> keyMapper); static Collection<T> difference(Collection<T> one, Collection<T> other, BiPredicate<T, T> equal); static int binarySearchLeftMost(List<T> items, Function<T, Integer> targetComparator); static Map<String, V> toLowerCaseKeys(Map<String, V> entries); static Map<String, V> toLowerCaseKeys(Map<String, V> entries, Supplier<Map<String, V>> mapSupplier);  }
@Test public void testContainsAnyKeys() { Map<String, String> map = new HashMap<>(); map.put("a", "1"); map.put("b", "2"); assertThat(CollectionsExt.containsAnyKeys(map, "a", "c")).isTrue(); assertThat(CollectionsExt.containsAnyKeys(map, "c", "a")).isTrue(); assertThat(CollectionsExt.containsAnyKeys(map, "c", "d")).isFalse(); }