Class IteratorHelper

java.lang.Object
com.helger.commons.collection.IteratorHelper

public final class IteratorHelper extends Object
Helper class containing several Iterator, Iterable, Enumeration etc. helper methods.
Author:
Philip Helger
  • Method Details

    • isEmpty

      public static boolean isEmpty(@Nullable Iterator<?> aIter)
    • isEmpty

      public static boolean isEmpty(@Nullable IIterableIterator<?> aIter)
    • isEmpty

      public static boolean isEmpty(@Nullable Enumeration<?> aEnum)
    • isNotEmpty

      public static boolean isNotEmpty(@Nullable Iterator<?> aIter)
    • isNotEmpty

      public static boolean isNotEmpty(@Nullable IIterableIterator<?> aIter)
    • isNotEmpty

      public static boolean isNotEmpty(@Nullable Enumeration<?> aEnum)
    • getSize

      @Nonnegative public static int getSize(@Nullable IIterableIterator<?> aIterator)
      Retrieve the size of the passed Iterable.
      Parameters:
      aIterator - Iterable iterator to check. May be null.
      Returns:
      The number objects or 0 if the passed parameter is null.
    • getSize

      @Nonnegative public static int getSize(@Nullable Iterator<?> aIterator)
      Retrieve the size of the passed Iterator.
      Parameters:
      aIterator - Iterator to check. May be null.
      Returns:
      The number objects or 0 if the passed parameter is null.
    • getSize

      @Nonnegative public static int getSize(@Nullable Enumeration<?> aEnumeration)
      Retrieve the size of the passed Enumeration.
      Parameters:
      aEnumeration - Enumeration to check. May be null.
      Returns:
      The number objects or 0 if the passed parameter is null.
    • getIterator

      @Nonnull public static <ELEMENTTYPE> IIterableIterator<ELEMENTTYPE> getIterator(@Nullable Enumeration<? extends ELEMENTTYPE> aEnum)
    • getIterator

      @Nonnull public static <ELEMENTTYPE> Iterator<ELEMENTTYPE> getIterator(@Nullable Iterable<ELEMENTTYPE> aCont)
    • getIterator

      @Nonnull public static <ELEMENTTYPE> Iterator<ELEMENTTYPE> getIterator(@Nullable Iterator<ELEMENTTYPE> aIter)
    • getIterator

      @Nonnull @SafeVarargs public static <ELEMENTTYPE> Iterator<ELEMENTTYPE> getIterator(@Nullable ELEMENTTYPE... aArray)
    • getReverseIterator

      @Nonnull public static <ELEMENTTYPE> Iterator<ELEMENTTYPE> getReverseIterator(@Nullable List<? extends ELEMENTTYPE> aCont)
    • getCombinedIterator

      @Nonnull public static <ELEMENTTYPE> Iterator<ELEMENTTYPE> getCombinedIterator(@Nullable Iterator<? extends ELEMENTTYPE> aIter1, @Nullable Iterator<? extends ELEMENTTYPE> aIter2)
      Get a merged iterator of both iterators. The first iterator is iterated first, the second one afterwards.
      Type Parameters:
      ELEMENTTYPE - The type of elements to be enumerated.
      Parameters:
      aIter1 - First iterator. May be null.
      aIter2 - Second iterator. May be null.
      Returns:
      The merged iterator. Never null.
    • getEnumeration

      @Nonnull public static <ELEMENTTYPE> Enumeration<ELEMENTTYPE> getEnumeration(@Nullable Iterable<ELEMENTTYPE> aCont)
      Get an Enumeration object based on a Collection object.
      Type Parameters:
      ELEMENTTYPE - the type of the elements in the container
      Parameters:
      aCont - The container to enumerate.
      Returns:
      an Enumeration object
    • getEnumeration

      @Nonnull @SafeVarargs public static <ELEMENTTYPE> Enumeration<ELEMENTTYPE> getEnumeration(@Nullable ELEMENTTYPE... aArray)
      Get an Enumeration object based on the passed array.
      Type Parameters:
      ELEMENTTYPE - the type of the elements in the container
      Parameters:
      aArray - The array to enumerate.
      Returns:
      an Enumeration object
    • getEnumeration

      @Nonnull public static <ELEMENTTYPE> Enumeration<ELEMENTTYPE> getEnumeration(@Nullable Iterator<ELEMENTTYPE> aIter)
      Get an Enumeration object based on an Iterator object.
      Type Parameters:
      ELEMENTTYPE - the type of the elements in the container
      Parameters:
      aIter - iterator object to use
      Returns:
      an Enumeration object
    • getEnumeration

      @Nonnull public static <KEYTYPE, VALUETYPE> Enumeration<Map.Entry<KEYTYPE,VALUETYPE>> getEnumeration(@Nullable Map<KEYTYPE,VALUETYPE> aMap)
      Get an Enumeration object based on a Map object.
      Type Parameters:
      KEYTYPE - map key type
      VALUETYPE - map value type
      Parameters:
      aMap - map object to use
      Returns:
      an Enumeration object