CollectionUtils { public static <T> Set<T> union(Set<T> a, Set<T> b) { Set<T> set = new HashSet<>(a); set.addAll(b); return set; }  static boolean isEmpty(Object[] array); static boolean isEmpty(Map<?, ?> map); static boolean isEmpty(Collection<?> collection); static Set<T> intersect(Set<T> a, Set<T> b); static Set<T> union(Set<T> a, Set<T> b); static boolean hasIntersection(Set<T> a, Set<T> b); @SafeVarargs static Set<T> newHashSet(T... values);  }
@Test void testUnion() { Set<Integer> a = newHashSet(2, 3, 4); Set<Integer> b = newHashSet(3, 4, 5, 6); Set<Integer> result = CollectionUtils.union(a, b); assertEquals(newHashSet(2, 3, 4, 5, 6), result); result = CollectionUtils.union(a, newHashSet()); assertEquals(a, result); }