@Test public void testUnion() { System.out.println("===[ testUnion ]==="); Collection<String> a = new HashSet<String>(); a.add("A1"); a.add("X"); a.add("Y"); Collection<String> b = new ArrayList<String>(); b.add("B1"); b.add("B2"); b.add("X"); Collection<String> c = new Vector<String>(); c.add("C1"); c.add("X"); c.add("Y"); Collection<String> union = MiscUtil.union(a,b,c); System.out.println("Union: "+union); assertEquals(6,union.size()); assertTrue(union.contains("A1")); assertTrue(union.contains("X")); assertTrue(union.contains("Y")); assertTrue(union.contains("B1")); assertTrue(union.contains("B2")); assertTrue(union.contains("C1")); }
@NotNull public static <T> Collection<T> union(Collection<T>... sets) { Set<T> resultSet = new HashSet<>(); for (Collection<T> set: sets) { if (set != null) { resultSet.addAll(set); } } return resultSet; }
MiscUtil { @NotNull public static <T> Collection<T> union(Collection<T>... sets) { Set<T> resultSet = new HashSet<>(); for (Collection<T> set: sets) { if (set != null) { resultSet.addAll(set); } } return resultSet; } }
MiscUtil { @NotNull public static <T> Collection<T> union(Collection<T>... sets) { Set<T> resultSet = new HashSet<>(); for (Collection<T> set: sets) { if (set != null) { resultSet.addAll(set); } } return resultSet; }  }
MiscUtil { @NotNull public static <T> Collection<T> union(Collection<T>... sets) { Set<T> resultSet = new HashSet<>(); for (Collection<T> set: sets) { if (set != null) { resultSet.addAll(set); } } return resultSet; }  @NotNull static Collection<T> union(Collection<T>... sets); static Collection<? extends T> unionExtends(Collection<? extends T>... sets); static boolean listEquals(List<T> a, List<T> b); static boolean unorderedCollectionEquals(Collection a, Collection b); static boolean unorderedCollectionCompare(Collection<T> a, Collection<T> b, final Comparator<T> comparator); static boolean unorderedCollectionEquals(Collection<A> a, Collection<B> b, HeteroComparator<A,B> comparator); static boolean unorderedArrayEquals(T[] a, T[] b); static boolean unorderedArrayEquals(T[] a, T[] b, Comparator<T> comparator); static int unorderedCollectionHashcode(Collection<T> collection, Predicate<T> filter); static String readFile(File file); static void copyFile(File sourceFile, File destFile); static void copyDirectory(File src, File dst); static Collection<T> createCollection(T... items); static Boolean and(Boolean... operands); static boolean equals(Object a, Object b); static XMLGregorianCalendar asXMLGregorianCalendar(java.util.Date date); static XMLGregorianCalendar asXMLGregorianCalendar(Long timeInMilis); static java.util.Date asDate(XMLGregorianCalendar xgc); static Long asLong(XMLGregorianCalendar xgc); static java.util.Date asDate(int year, int month, int date, int hrs, int min, int sec); static void carthesian(Collection<Collection<T>> dimensions, Processor<Collection<T>> processor); static String concat(Collection<String> stringCollection); static boolean isAllNull(Collection<?> collection); static String getValueWithClass(Object object); static boolean isNoValue(Collection<?> collection); static boolean hasNoValue(Collection<?> collection); static Map<K,V> cloneMap(Map<K, V> orig); static String toString(Object o); static List<String> splitLines(String string); static boolean isBetween(XMLGregorianCalendar date, XMLGregorianCalendar start, XMLGregorianCalendar end); static boolean contains(T element, T[] array); static String stripHtmlMarkup(String htmlString); static Collection<T> getValuesFromDisplayableValues(Collection<? extends DisplayableValue<T>> disps); static String binaryToHex(byte[] bytes); static byte[] hexToBinary(String hex); static void addAllIfNotPresent(List<T> receivingList, List<T> supplyingList); static void addIfNotPresent(List<T> receivingList, T supplyingElement); static boolean nullableCollectionsEqual(Collection<?> c1, Collection<?> c2); static String getObjectName(Object o); static Integer compareNullLast(Object o1, Object o2); @SafeVarargs static T getFirstNonNull(T... values); static String getFirstNonNullString(Object... values); static T extractSingleton(Collection<T> collection); static boolean isCollectionOf(Object object, @NotNull Class<?> memberClass); static Function<Object, Stream<E>> instancesOf(Class<E> cls); static T last(List<T> list); static String emptyIfNull(String s); static boolean hasDuplicates(Collection<T> collection); static String formatExceptionMessageWithCause(Throwable t); static String formatExceptionMessageWithCause(Throwable t, int indent); }
MiscUtil { @NotNull public static <T> Collection<T> union(Collection<T>... sets) { Set<T> resultSet = new HashSet<>(); for (Collection<T> set: sets) { if (set != null) { resultSet.addAll(set); } } return resultSet; }  @NotNull static Collection<T> union(Collection<T>... sets); static Collection<? extends T> unionExtends(Collection<? extends T>... sets); static boolean listEquals(List<T> a, List<T> b); static boolean unorderedCollectionEquals(Collection a, Collection b); static boolean unorderedCollectionCompare(Collection<T> a, Collection<T> b, final Comparator<T> comparator); static boolean unorderedCollectionEquals(Collection<A> a, Collection<B> b, HeteroComparator<A,B> comparator); static boolean unorderedArrayEquals(T[] a, T[] b); static boolean unorderedArrayEquals(T[] a, T[] b, Comparator<T> comparator); static int unorderedCollectionHashcode(Collection<T> collection, Predicate<T> filter); static String readFile(File file); static void copyFile(File sourceFile, File destFile); static void copyDirectory(File src, File dst); static Collection<T> createCollection(T... items); static Boolean and(Boolean... operands); static boolean equals(Object a, Object b); static XMLGregorianCalendar asXMLGregorianCalendar(java.util.Date date); static XMLGregorianCalendar asXMLGregorianCalendar(Long timeInMilis); static java.util.Date asDate(XMLGregorianCalendar xgc); static Long asLong(XMLGregorianCalendar xgc); static java.util.Date asDate(int year, int month, int date, int hrs, int min, int sec); static void carthesian(Collection<Collection<T>> dimensions, Processor<Collection<T>> processor); static String concat(Collection<String> stringCollection); static boolean isAllNull(Collection<?> collection); static String getValueWithClass(Object object); static boolean isNoValue(Collection<?> collection); static boolean hasNoValue(Collection<?> collection); static Map<K,V> cloneMap(Map<K, V> orig); static String toString(Object o); static List<String> splitLines(String string); static boolean isBetween(XMLGregorianCalendar date, XMLGregorianCalendar start, XMLGregorianCalendar end); static boolean contains(T element, T[] array); static String stripHtmlMarkup(String htmlString); static Collection<T> getValuesFromDisplayableValues(Collection<? extends DisplayableValue<T>> disps); static String binaryToHex(byte[] bytes); static byte[] hexToBinary(String hex); static void addAllIfNotPresent(List<T> receivingList, List<T> supplyingList); static void addIfNotPresent(List<T> receivingList, T supplyingElement); static boolean nullableCollectionsEqual(Collection<?> c1, Collection<?> c2); static String getObjectName(Object o); static Integer compareNullLast(Object o1, Object o2); @SafeVarargs static T getFirstNonNull(T... values); static String getFirstNonNullString(Object... values); static T extractSingleton(Collection<T> collection); static boolean isCollectionOf(Object object, @NotNull Class<?> memberClass); static Function<Object, Stream<E>> instancesOf(Class<E> cls); static T last(List<T> list); static String emptyIfNull(String s); static boolean hasDuplicates(Collection<T> collection); static String formatExceptionMessageWithCause(Throwable t); static String formatExceptionMessageWithCause(Throwable t, int indent);  }