Package org.fest.util

Class Collections

java.lang.Object
org.fest.util.Collections

public final class Collections extends Object
Utility methods related to Collections.
Author:
Yvonne Wang, Alex Ruiz, Joel Costigliola
  • Method Details

    • duplicatesFrom

      public static <T> Collection<T> duplicatesFrom(Collection<T> c)
      Returns any duplicate elements from the given Collection.
      Type Parameters:
      T - the generic type of the given Collection.
      Parameters:
      c - the given Collection that might have duplicate elements.
      Returns:
      a Collection containing the duplicate elements of the given one. If no duplicates are found, an empty Collection is returned.
    • isNullOrEmpty

      public static boolean isNullOrEmpty(Collection<?> c)
      Indicates whether the given Collection is null or empty.
      Parameters:
      c - the given Collection.
      Returns:
      true if the given Collection is null or empty, otherwise false.
    • format

      public static String format(Collection<?> c)
      Returns the String representation of the given Collection, or null if the given Collection is null.
      Parameters:
      c - the Collection to format.
      Returns:
      the String representation of the given Collection.
    • nonNullElementsIn

      public static <T> List<T> nonNullElementsIn(Collection<T> c)
      Returns all the non-null elements in the given Collection.
      Type Parameters:
      T - the type of elements of the Collection.
      Parameters:
      c - the given Collection.
      Returns:
      all the non-null elements in the given Collection. An empty list is returned if the given Collection is null.
      Since:
      1.1.3