Class MiscUtil

  • public class MiscUtil
    extends Object
    • Constructor Detail

      • MiscUtil

        public MiscUtil()
    • Method Detail

      • unionExtends

        public static <T> Collection<? extends T> unionExtends​(Collection<? extends T>... sets)
      • listEquals

        public static <T> boolean listEquals​(List<T> a,
                                             List<T> b)
      • unorderedCollectionEquals

        public static <T> boolean unorderedCollectionEquals​(Collection<T> a,
                                                            Collection<T> b)
      • unorderedCollectionCompare

        public static <T> boolean unorderedCollectionCompare​(Collection<T> a,
                                                             Collection<T> b,
                                                             Comparator<T> comparator)
        Only zero vs non-zero value of comparator is important.
      • unorderedCollectionEquals

        public static <A,​B> boolean unorderedCollectionEquals​(Collection<A> a,
                                                                    Collection<B> b,
                                                                    HeteroComparator<A,​B> comparator)
        Only zero vs non-zero value of comparator is important.
      • unorderedArrayEquals

        public static <T> boolean unorderedArrayEquals​(T[] a,
                                                       T[] b)
      • unorderedArrayEquals

        public static <T> boolean unorderedArrayEquals​(T[] a,
                                                       T[] b,
                                                       Comparator<T> comparator)
        Only zero vs non-zero value of comparator is important.
      • unorderedCollectionHashcode

        public static <T> int unorderedCollectionHashcode​(Collection<T> collection,
                                                          Predicate<T> filter)
      • copyDirectory

        public static void copyDirectory​(File src,
                                         File dst)
                                  throws IOException
        Copy a directory and its contents.
        src - The name of the directory to copy.
        dst - The name of the destination directory.
        IOException - If the directory could not be copied.
      • and

        public static Boolean and​(Boolean... operands)
        n-ary and that ignores null values.
      • equals

        public static boolean equals​(Object a,
                                     Object b)
      • asXMLGregorianCalendar

        public static XMLGregorianCalendar asXMLGregorianCalendar​(Date date)
        Converts a java.util.Date into an instance of XMLGregorianCalendar
        date - Instance of java.util.Date or a null reference
        XMLGregorianCalendar instance whose value is based upon the value in the date parameter. If the date parameter is null then this method will simply return null.
      • asDate

        public static Date asDate​(XMLGregorianCalendar xgc)
        Converts an XMLGregorianCalendar to an instance of java.util.Date
        xgc - Instance of XMLGregorianCalendar or a null reference
        java.util.Date instance whose value is based upon the value in the xgc parameter. If the xgc parameter is null then this method will simply return null.
      • asDate

        public static Date asDate​(int year,
                                  int month,
                                  int date,
                                  int hrs,
                                  int min,
                                  int sec)
      • isAllNull

        public static boolean isAllNull​(Collection<?> collection)
      • getValueWithClass

        public static String getValueWithClass​(Object object)
      • getClass

        public static String getClass​(Object object)
      • isNoValue

        public static boolean isNoValue​(Collection<?> collection)
      • hasNoValue

        public static boolean hasNoValue​(Collection<?> collection)
      • cloneMap

        public static <K,​V> Map<K,​V> cloneMap​(Map<K,​V> orig)
        Shallow clone
      • contains

        public static <T> boolean contains​(T element,
                                           T[] array)
      • stripHtmlMarkup

        public static String stripHtmlMarkup​(String htmlString)
      • binaryToHex

        public static String binaryToHex​(byte[] bytes)
      • hexToBinary

        public static byte[] hexToBinary​(String hex)
      • hexToUtf8String

        public static String hexToUtf8String​(String hex)
      • addAllIfNotPresent

        public static <T> void addAllIfNotPresent​(List<T> receivingList,
                                                  List<T> supplyingList)
      • addIfNotPresent

        public static <T> void addIfNotPresent​(List<T> receivingList,
                                               T supplyingElement)
      • nullableCollectionsEqual

        public static boolean nullableCollectionsEqual​(Collection<?> c1,
                                                       Collection<?> c2)
      • getObjectName

        public static String getObjectName​(Object o)
      • getFirstNonNull

        public static <T> T getFirstNonNull​(T... values)
      • getFirstNonNullString

        public static String getFirstNonNullString​(Object... values)
      • extractSingleton

        public static <T> T extractSingleton​(Collection<T> collection)
      • getSingleValue

        public static <T> T getSingleValue​(Collection<T> values,
                                           T defaultValue,
                                           String contextDescription)
      • isCollectionOf

        public static boolean isCollectionOf​(Object object,
                                             Class<?> memberClass)
      • last

        public static <T> T last​(List<T> list)
      • emptyIfNull

        public static String emptyIfNull​(String s)
      • emptyIfNull

        public static <T> List<T> emptyIfNull​(List<T> list)
      • streamOf

        public static <T> Stream<T> streamOf​(Collection<T> collection)
      • nullIfEmpty

        public static String nullIfEmpty​(String s)
      • hasDuplicates

        public static <T> boolean hasDuplicates​(Collection<T> collection)
        Returns true if the collection contains at least one pair of equals elements.
      • formatExceptionMessageWithCause

        public static String formatExceptionMessageWithCause​(Throwable t)
      • formatExceptionMessageWithCause

        public static String formatExceptionMessageWithCause​(Throwable t,
                                                             int indent)
      • throwExceptionAsUnchecked

        public static void throwExceptionAsUnchecked​(Throwable t)
      • filter

        public static <T> Set<T> filter​(Set<T> input,
                                        Predicate<? super T> predicate)
      • nonNullValues

        public static <V> Collection<V> nonNullValues​(@NotNull
                                                      Collection<V> values)
      • toUrlUnchecked

        public static URL toUrlUnchecked​(URI uri)
      • takeThreadDump

        public static String takeThreadDump​(@Nullable
                                            Thread thread)
        Thanks for this code go to
      • paramsToMap

        public static <K,​V> Map<K,​V> paramsToMap​(Object[] params)