Package nl.vpro.util
Class TailAdder<T>
java.lang.Object
nl.vpro.util.TailAdder<T>
- All Implemented Interfaces:
AutoCloseable
,Iterator<T>
,CloseableIterator<T>
,Counted
,CountedIterator<T>
Adapts an existing iterator, to add elements at the end, perhaps based on the last element.
- Since:
- 1.17
- Author:
- Michiel Meeuwissen
-
Nested Class Summary
Nested classes/interfaces inherited from interface nl.vpro.util.CloseableIterator
CloseableIterator.WrappedCloseableIterator<S>, CloseableIterator.WrappedPeekingCloseableIterator<S>
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic <T> TailAdder.Builder<T>
builder()
void
close()
getCount()
The current position.protected T
getLast()
getSize()
The size, if known, of the collection this iterator is representingboolean
hasNext()
next()
void
remove()
toString()
static <T> TailAdder<T>
withFunctions
(Iterator<T> wrapped, Function<T, T>... adder) 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
getTotalSize, peeking, spliterator, stream
Methods inherited from interface java.util.Iterator
forEachRemaining
-
Constructor Details
-
TailAdder
@SafeVarargs @Deprecated public TailAdder(Iterator<T> wrapped, boolean onlyIfEmpty, Callable<T>... adder) Deprecated. -
TailAdder
Deprecated.
-
-
Method Details
-
withFunctions
@SafeVarargs public static <T> TailAdder<T> withFunctions(Iterator<T> wrapped, Function<T, T>... adder) -
hasNext
public boolean hasNext() -
next
-
getLast
-
remove
public void remove() -
getSize
Description copied from interface:CountedIterator
The size, if known, of the collection this iterator is representing- Specified by:
getSize
in interfaceCountedIterator<T>
-
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>
-
close
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCountedIterator<T>
- Throws:
Exception
-
toString
-
builder
-