Package com.saperion.util
Class IteratorIterable<Type>
- java.lang.Object
-
- com.saperion.util.IteratorIterable<Type>
-
- All Implemented Interfaces:
java.lang.Iterable<Type>
public class IteratorIterable<Type> extends java.lang.Object implements java.lang.Iterable<Type>
For a givenIterator
anIteratorIterable
is a correspondingIterable
- and thus usable in the extended for-syntax.
-
-
Constructor Summary
Constructors Constructor Description IteratorIterable(java.util.Iterator<Type> iterator)
Creates a newIteratorIterable
for the givenIterator
-
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 givenIterator
this method returns anIterable
whoseIterable.iterator()
will return exactly that iterator.java.util.Iterator<Type>
iterator()
-
-
-
Constructor Detail
-
IteratorIterable
public IteratorIterable(java.util.Iterator<Type> iterator)
Creates a newIteratorIterable
for the givenIterator
- Parameters:
iterator
- the iterator to iterate. Must not be null.
-
-
Method Detail
-
iterator
public java.util.Iterator<Type> iterator()
- Specified by:
iterator
in interfacejava.lang.Iterable<Type>
-
create
public static <Type> IteratorIterable<Type> create(java.util.Iterator<Type> iterator)
For a givenIterator
this method returns anIterable
whoseIterable.iterator()
will return exactly that iterator.- Type Parameters:
Type
- The generic type of theIterator
. The whole point of this method is to make the compiler determine this type.- Parameters:
iterator
- theIterator
to create anIterable
for. Must not be null.- Returns:
- an
Iterable
whoseIterable.iterator()
will return the givenIterator
.
-
-