Package org.fest.util

Class Collections


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

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static <T> java.util.Collection<T> duplicatesFrom​(java.util.Collection<T> c)
      Returns any duplicate elements from the given Collection.
      static java.lang.String format​(java.util.Collection<?> c)
      Returns the String representation of the given Collection, or null if the given Collection is null.
      static boolean isNullOrEmpty​(java.util.Collection<?> c)
      Indicates whether the given Collection is null or empty.
      static <T> java.util.List<T> nonNullElementsIn​(java.util.Collection<T> c)
      Returns all the non-null elements in the given Collection.
      • Methods inherited from class java.lang.Object

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

      • duplicatesFrom

        public static <T> java.util.Collection<T> duplicatesFrom​(java.util.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​(java.util.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 java.lang.String format​(java.util.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> java.util.List<T> nonNullElementsIn​(java.util.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