Package org.apache.pivot.util
Class ImmutableIterator<T>
- java.lang.Object
-
- org.apache.pivot.util.ImmutableIterator<T>
-
- Type Parameters:
T
- The type of elements we are iterating over.
- All Implemented Interfaces:
java.util.Iterator<T>
public final class ImmutableIterator<T> extends java.lang.Object implements java.util.Iterator<T>
Immutable implementation of theIterator
interface.The only methods that have actual implementations (that just defer to the underlying
Iterator
) are:hasNext()
andnext()
.Note: the
remove()
method implementation here has been taken out because there is now a default implementation in theIterator
interface itself in Java 8.
-
-
Constructor Summary
Constructors Constructor Description ImmutableIterator(java.util.Iterator<T> iter)
Construct an immutable iterator over the base iterator given here.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
hasNext()
T
next()
-
-
-
Constructor Detail
-
ImmutableIterator
public ImmutableIterator(java.util.Iterator<T> iter)
Construct an immutable iterator over the base iterator given here.- Parameters:
iter
- The base iterator we want to protect from change.- Throws:
java.lang.IllegalArgumentException
- if the iterator isnull
.
-
-