Class CollectionUtils

java.lang.Object
nonapi.io.github.classgraph.utils.CollectionUtils

public final class CollectionUtils extends Object
Collection utilities.
  • Constructor Details

    • CollectionUtils

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

    • sortIfNotEmpty

      public static <T extends Comparable<? super T>> void sortIfNotEmpty(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(List<T> list, 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 Comparable<T>> List<T> sortCopy(Collection<T> elts)
      Copy and sort a collection.
      Parameters:
      elts - the collection to copy and sort
      Returns:
      a sorted copy of the collection