Package org.openrefine.util
Class CloseableIterator.Wrapper<T>
- java.lang.Object
-
- org.openrefine.util.CloseableIterator.Wrapper<T>
-
- All Implemented Interfaces:
io.vavr.collection.Foldable<T>
,io.vavr.collection.Iterator<T>
,io.vavr.collection.Traversable<T>
,io.vavr.Value<T>
,AutoCloseable
,Iterable<T>
,Iterator<T>
,CloseableIterator<T>
- Enclosing interface:
- CloseableIterator<T>
public static class CloseableIterator.Wrapper<T> extends Object implements CloseableIterator<T>
A wrapper which takes a plain iterator and turns it into a closeable one. A list of closeable resources can be supplied: when this iterator is closed, all those closeables will be closed as well.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.openrefine.util.CloseableIterator
CloseableIterator.Wrapper<T>
-
-
Constructor Summary
Constructors Constructor Description Wrapper(io.vavr.collection.Iterator<T> iterator, io.vavr.collection.List<AutoCloseable> toClose)
Wraps a plain iterator, supplying a list of closeables to be closed when the resultingCloseableIterator
is closed.Wrapper(io.vavr.collection.Iterator<T> iterator, AutoCloseable toClose)
Convenience constructor when there is only one underlying closeable.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
Releases all resources underpinning this iterator.boolean
hasNext()
Checks if the iterator contains a next element.T
next()
Returns the next element in the stream if there is one available.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.openrefine.util.CloseableIterator
chop, collect, concat, distinct, distinctBy, distinctBy, drop, dropRight, dropUntil, dropWhile, filter, flatMap, flatMapCloseable, grouped, init, intersperse, iterator, map, orElse, orElse, orElse, peek, reject, replace, replaceAll, retainAll, scanLeft, scanRight, slideBy, sliding, sliding, tail, take, takeRight, takeUntil, takeWhile, zip, zip, zipAll, zipAll, zipWith, zipWith, zipWithIndex, zipWithIndex
-
Methods inherited from interface io.vavr.collection.Iterator
concat, findLast, foldRight, get, groupBy, hasDefiniteSize, head, initOption, isAsync, isEmpty, isLazy, isSequential, isTraversableAgain, last, length, partition, reduceLeft, reduceRight, scan, span, stringPrefix, tailOption, transform, unzip, unzip3
-
Methods inherited from interface java.util.Iterator
forEachRemaining, remove
-
Methods inherited from interface io.vavr.collection.Traversable
arrangeBy, average, containsAll, count, equals, existsUnique, find, foldLeft, forEachWithIndex, hashCode, headOption, isDistinct, isOrdered, isSingleValued, lastOption, max, maxBy, maxBy, min, minBy, minBy, mkCharSeq, mkCharSeq, mkCharSeq, mkString, mkString, mkString, nonEmpty, product, reduceLeftOption, reduceRightOption, single, singleOption, size, spliterator, sum
-
Methods inherited from interface io.vavr.Value
collect, collect, contains, corresponds, eq, exists, forAll, forEach, getOrElse, getOrElse, getOrElseThrow, getOrElseTry, getOrNull, out, out, stderr, stdout, toArray, toCharSeq, toCompletableFuture, toEither, toEither, toInvalid, toInvalid, toJavaArray, toJavaArray, toJavaArray, toJavaCollection, toJavaList, toJavaList, toJavaMap, toJavaMap, toJavaMap, toJavaOptional, toJavaParallelStream, toJavaSet, toJavaSet, toJavaStream, toLeft, toLeft, toLinkedMap, toLinkedMap, toLinkedSet, toList, toMap, toMap, toOption, toPriorityQueue, toPriorityQueue, toQueue, toRight, toRight, toSet, toSortedMap, toSortedMap, toSortedMap, toSortedMap, toSortedSet, toSortedSet, toStream, toString, toTree, toTree, toTry, toTry, toValid, toValid, toValidation, toValidation, toVector
-
-
-
-
Constructor Detail
-
Wrapper
public Wrapper(io.vavr.collection.Iterator<T> iterator, io.vavr.collection.List<AutoCloseable> toClose)
Wraps a plain iterator, supplying a list of closeables to be closed when the resultingCloseableIterator
is closed.
-
Wrapper
public Wrapper(io.vavr.collection.Iterator<T> iterator, AutoCloseable toClose)
Convenience constructor when there is only one underlying closeable.
-
-
Method Detail
-
close
public void close()
Description copied from interface:CloseableIterator
Releases all resources underpinning this iterator. Calling this method multiple times is allowed but calling it only once is sufficient. TheCloseableIterator.next()
method may not be called after this one is called.- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseableIterator<T>
-
hasNext
public boolean hasNext()
Description copied from interface:CloseableIterator
Checks if the iterator contains a next element. If this returns false, the iterator should already be closed: it is not necessary to callCloseableIterator.close()
after that.
-
next
public T next()
Description copied from interface:CloseableIterator
Returns the next element in the stream if there is one available. This may not be called after callingCloseableIterator.close()
.
-
-