Package nl.vpro.util
Class WrappedIterator<T,S>
- java.lang.Object
-
- nl.vpro.util.WrappedIterator<T,S>
-
- All Implemented Interfaces:
AutoCloseable
,Iterator<S>
,CloseableIterator<S>
,Counted
,CountedIterator<S>
- Direct Known Subclasses:
BasicWrappedIterator
public abstract class WrappedIterator<T,S> extends Object implements CountedIterator<S>
- Since:
- 1.3
- Author:
- Michiel Meeuwissen
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface nl.vpro.util.CloseableIterator
CloseableIterator.WrappedCloseableIterator<S>, CloseableIterator.WrappedPeekingCloseableIterator<S>
-
-
Field Summary
Fields Modifier and Type Field Description protected CloseableIterator<T>
wrapped
-
Constructor Summary
Constructors Constructor Description WrappedIterator(Iterator<T> wrapped)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description void
close()
Long
getCount()
The current position.@NonNull Optional<Long>
getSize()
The size, if known, of the collection this iterator is representing@NonNull Optional<Long>
getTotalSize()
If the iterator is in some way restricted you may also want to report a total size, representing the unrestricted size.boolean
hasNext()
protected Iterator<T>
iterator()
abstract S
next()
void
remove()
String
toString()
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface nl.vpro.util.CountedIterator
peeking, spliterator, stream
-
Methods inherited from interface java.util.Iterator
forEachRemaining
-
-
-
-
Field Detail
-
wrapped
protected final CloseableIterator<T> wrapped
-
-
Method Detail
-
getSize
public @NonNull Optional<Long> getSize()
Description copied from interface:CountedIterator
The size, if known, of the collection this iterator is representing- Specified by:
getSize
in interfaceCountedIterator<T>
-
getCount
public Long getCount()
Description copied from interface:CountedIterator
The current position. Will return1
after first successfull call toIterator.next()
,2
after the second one, and so on. It will return0
before the first call.- Specified by:
getCount
in interfaceCounted
- Specified by:
getCount
in interfaceCountedIterator<T>
-
getTotalSize
public @NonNull Optional<Long> getTotalSize()
Description copied from interface:CountedIterator
If the iterator is in some way restricted you may also want to report a total size, representing the unrestricted size.The default implementation is
CountedIterator.getSize()
.- Specified by:
getTotalSize
in interfaceCountedIterator<T>
-
close
public void close() throws Exception
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCountedIterator<T>
- Throws:
Exception
-
-