Class IterableUtils


  • public final class IterableUtils
    extends Object
    • Constructor Detail

      • IterableUtils

        public IterableUtils()
    • Method Detail

      • firstOrNull

        public static <T> T firstOrNull​(Iterable<T> iterable)
        Similar to the first method from Apache Commons, but returns null instead of throwing if the iterable is empty.
        Type Parameters:
        T - Type of the items in the iterable.
        Parameters:
        iterable - Iterable to process.
        Returns:
        The first item in the iterable, or null if either the iterable is null or it contains no items.