net.aavalla.utils.general
Class ReadonlyIterator<T>
java.lang.Object
net.aavalla.utils.general.ReadonlyIterator<T>
- Type Parameters:
T
- Type of items stored in the collection
- All Implemented Interfaces:
- java.util.Iterator<T>
public final class ReadonlyIterator<T>
- extends java.lang.Object
- implements java.util.Iterator<T>
This class represents a read only iterator for any Collection object. It
uses the default iterator, but there is one difference: remove() method is
overwritten with an empty method.
- Author:
- Lari Natri
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
ReadonlyIterator
public ReadonlyIterator(java.util.Collection<T> collection)
- Constructor
- Parameters:
collection
- Collection to iterate
hasNext
public final boolean hasNext()
- Specified by:
hasNext
in interface java.util.Iterator<T>
next
public final T next()
- Specified by:
next
in interface java.util.Iterator<T>
remove
@Deprecated
public final void remove()
throws java.lang.UnsupportedOperationException
- Deprecated.
- Do not call this mehtod. This method only throws an exception
and does nothing else. It does not remove any items.
- Specified by:
remove
in interface java.util.Iterator<T>
- Throws:
java.lang.UnsupportedOperationException
- Thrown always
when this method is called.