Package org.fest.util

Class Iterables


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

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static boolean isNullOrEmpty​(java.lang.Iterable<?> iterable)
      Indicates whether the given Iterable is null or empty.
      static <T> java.util.List<T> nonNullElementsIn​(java.lang.Iterable<T> i)
      Returns all the non-null elements in the given Iterable.
      static int sizeOf​(java.lang.Iterable<?> iterable)
      Returns the size of the given Iterable.
      • Methods inherited from class java.lang.Object

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

      • isNullOrEmpty

        public static boolean isNullOrEmpty​(java.lang.Iterable<?> iterable)
        Indicates whether the given Iterable is null or empty.
        Parameters:
        iterable - the given Iterable to check.
        Returns:
        true if the given Iterable is null or empty, otherwise false.
      • sizeOf

        public static int sizeOf​(java.lang.Iterable<?> iterable)
        Returns the size of the given Iterable.
        Parameters:
        iterable - the Iterable to get size.
        Returns:
        the size of the given Iterable.
        Throws:
        java.lang.NullPointerException - if given Iterable is null.
      • nonNullElementsIn

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