Class CollectionUtils


  • public final class CollectionUtils
    extends java.lang.Object
    Collection utilities.
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      private CollectionUtils()
      Class can't be constructed.
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static <T extends java.lang.Comparable<T>>
      java.util.List<T>
      sortCopy​(java.util.Collection<T> elts)
      Copy and sort a collection.
      static <T extends java.lang.Comparable<? super T>>
      void
      sortIfNotEmpty​(java.util.List<T> list)
      Sort a collection if it is not empty (to prevent ConcurrentModificationException if an immutable empty list that has been returned more than once is being sorted in one thread and iterated through in another thread -- #334).
      static <T> void sortIfNotEmpty​(java.util.List<T> list, java.util.Comparator<? super T> comparator)
      Sort a collection if it is not empty (to prevent ConcurrentModificationException if an immutable empty list that has been returned more than once is being sorted in one thread and iterated through in another thread -- #334).
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • CollectionUtils

        private CollectionUtils()
        Class can't be constructed.
    • Method Detail

      • sortIfNotEmpty

        public static <T extends java.lang.Comparable<? super T>> void sortIfNotEmpty​(java.util.List<T> list)
        Sort a collection if it is not empty (to prevent ConcurrentModificationException if an immutable empty list that has been returned more than once is being sorted in one thread and iterated through in another thread -- #334).
        Type Parameters:
        T - the element type
        Parameters:
        list - the list
      • sortIfNotEmpty

        public static <T> void sortIfNotEmpty​(java.util.List<T> list,
                                              java.util.Comparator<? super T> comparator)
        Sort a collection if it is not empty (to prevent ConcurrentModificationException if an immutable empty list that has been returned more than once is being sorted in one thread and iterated through in another thread -- #334).
        Type Parameters:
        T - the element type
        Parameters:
        list - the list
        comparator - the comparator
      • sortCopy

        public static <T extends java.lang.Comparable<T>> java.util.List<T> sortCopy​(java.util.Collection<T> elts)
        Copy and sort a collection.
        Parameters:
        elts - the collection to copy and sort
        Returns:
        a sorted copy of the collection