com.evanmclean.evlib.util
Class UnmodifiableIterator<E>

java.lang.Object
  extended by com.evanmclean.evlib.util.UnmodifiableIterator<E>
Type Parameters:
E -
All Implemented Interfaces:
Iterator<E>

public class UnmodifiableIterator<E>
extends Object
implements Iterator<E>

Wrapper around an Iterable or an Iterator that makes an iterator that will throw an UnsupportedOperationException if remove() is called.

Author:
Evan McLean McLean Computer Services (see the overview for copyright and licensing.)

Constructor Summary
UnmodifiableIterator(Iterable<? extends E> iterable)
           
UnmodifiableIterator(Iterator<? extends E> iterator)
           
 
Method Summary
static
<E> UnmodifiableIterator<E>
create(Iterable<? extends E> iterable)
           
static
<E> UnmodifiableIterator<E>
create(Iterator<? extends E> iterator)
           
 boolean hasNext()
           
 E next()
           
 void remove()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

UnmodifiableIterator

public UnmodifiableIterator(Iterable<? extends E> iterable)

UnmodifiableIterator

public UnmodifiableIterator(Iterator<? extends E> iterator)
Method Detail

create

public static <E> UnmodifiableIterator<E> create(Iterable<? extends E> iterable)

create

public static <E> UnmodifiableIterator<E> create(Iterator<? extends E> iterator)

hasNext

public boolean hasNext()
Specified by:
hasNext in interface Iterator<E>

next

public E next()
Specified by:
next in interface Iterator<E>

remove

public void remove()
Specified by:
remove in interface Iterator<E>