Class IteratorIterable<Type>

  • All Implemented Interfaces:
    java.lang.Iterable<Type>

    public class IteratorIterable<Type>
    extends java.lang.Object
    implements java.lang.Iterable<Type>
    For a given Iterator an IteratorIterable is a corresponding Iterable - and thus usable in the extended for-syntax.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      static <Type> IteratorIterable<Type> create​(java.util.Iterator<Type> iterator)
      For a given Iterator this method returns an Iterable whose Iterable.iterator() will return exactly that iterator.
      java.util.Iterator<Type> iterator()
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
      • Methods inherited from interface java.lang.Iterable

        forEach, spliterator
    • Constructor Detail

      • IteratorIterable

        public IteratorIterable​(java.util.Iterator<Type> iterator)
        Creates a new IteratorIterable for the given Iterator
        Parameters:
        iterator - the iterator to iterate. Must not be null.
    • Method Detail

      • iterator

        public java.util.Iterator<Type> iterator()
        Specified by:
        iterator in interface java.lang.Iterable<Type>
      • create

        public static <Type> IteratorIterable<Type> create​(java.util.Iterator<Type> iterator)
        For a given Iterator this method returns an Iterable whose Iterable.iterator() will return exactly that iterator.
        Type Parameters:
        Type - The generic type of the Iterator. The whole point of this method is to make the compiler determine this type.
        Parameters:
        iterator - the Iterator to create an Iterable for. Must not be null.
        Returns:
        an Iterable whose Iterable.iterator() will return the given Iterator.