Package com.complexible.common.base
Interface CloseableIterator<T>
-
- All Superinterfaces:
java.lang.AutoCloseable
,java.util.Iterator<T>
- All Known Subinterfaces:
BindingSetIterator
,BooleanQueryResult
,GraphQueryResult
,MarkResetIterator<T>
,PathQueryResult
,PeekingSkippingIterator<T>
,QueryResult<T>
,ResettableIterator<T>
,RestrictedMarkResetIterator<T>
,SelectQueryResult
,SkippingIterator<T>
,StatementIterator
- All Known Implementing Classes:
AbstractSkippingIterator
,AsyncGraphQueryResult
,AsyncSelectQueryResult
,CloseableIterator.AbstractCloseableIterator
,CloseableIterator.DelegatingCloseableIterator
,CloseableIterator.EmptyCloseableIterator
,DelegatingSkippingIterator
,GraphQueryResultIterator
,HandlerBackedIterator
,IOBindingSetIterator
,IteratorAsBooleanQueryResult
,IteratorAsGraphQueryResult
,IteratorAsPathQueryResult
,IteratorAsTupleQueryResult
,MarkResetSkippingIterator
,MultiStatementIterator
,PathsAsTupleQueryResult
,SpoolingMarkResetIterator
,TupleQueryResultIterator
,TuplesAsPathQueryResult
public interface CloseableIterator<T> extends java.util.Iterator<T>, java.lang.AutoCloseable
An
Iterator
which can beclosed
.- Since:
- 4.0
- Version:
- 7.4.2
- Author:
- Michael Grove
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static class
CloseableIterator.AbstractCloseableIterator<T>
static class
CloseableIterator.DelegatingCloseableIterator<T>
static class
CloseableIterator.EmptyCloseableIterator<T>
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Modifier and Type Method Description void
close()
static void
closeQuietly(java.util.Iterator<?> theIterator)
static <T,A,R>
Rcollect(CloseableIterator<T> theIter, java.util.stream.Collector<T,A,R> theCollector)
Collect the contents of the iterator.static <I> CloseableIterator<I>
concat(CloseableIterator<I> theFirst, CloseableIterator<I> theSecond)
static <T> CloseableIterator<T>
concat(java.lang.Iterable<? extends CloseableIterator<T>> theIters)
static <T> CloseableIterator<T>
concat(java.util.Iterator<? extends CloseableIterator<T>> inputs)
static <T> CloseableIterator<T>
empty()
static <T> CloseableIterator<T>
filter(CloseableIterator<T> theIter, java.util.function.Predicate<T> thePredicate)
static <T> java.util.Optional<T>
first(CloseableIterator<T> theIter)
Get the first element in the iterator.static boolean
isEmpty(CloseableIterator<?> theIterator)
static <T> CloseableIterator<T>
limit(CloseableIterator<T> theIter, long theLimit)
static <I,O>
CloseableIterator<O>map(CloseableIterator<I> theIterator, java.util.function.Function<? super I,O> theFunction)
static <T> CloseableIterator<T>
offset(CloseableIterator<T> theIter, long theOffset)
static <T> CloseableIterator<T>
onClose(CloseableIterator<T> theIter, java.lang.Runnable theRunnable)
static <T> CloseableIterator<T>
singleton(T theElem)
static <T> long
size(CloseableIterator<T> theIter)
Return the number of elements in the iterator.static <T> CloseableIterator<T>
toCloseable(java.util.Iterator<? extends T> theIterator)
static <T> CloseableIterator<T>
toCloseable(java.util.Iterator<? extends T> theIterator, java.lang.Runnable theOnClose)
static <T> CloseableIterator<T>
toCloseable(java.util.stream.Stream<T> theStream)
static <T> java.util.List<T>
toList(CloseableIterator<T> theIter)
Collect the contents of the iterator as aList
.static <T> java.util.Set<T>
toSet(CloseableIterator<T> theIter)
Collect the contents of the iterator as aSet
.static <In,Out>
CloseableIterator<Out>transform(CloseableIterator<In> theIter, java.util.function.Function<In,Out> theFunction)
-
-
-
Method Detail
-
close
void close() throws java.lang.RuntimeException
- Specified by:
close
in interfacejava.lang.AutoCloseable
- Throws:
java.lang.RuntimeException
-
onClose
@MustBeClosed static <T> CloseableIterator<T> onClose(CloseableIterator<T> theIter, java.lang.Runnable theRunnable)
-
closeQuietly
static void closeQuietly(java.util.Iterator<?> theIterator)
-
empty
static <T> CloseableIterator<T> empty()
-
singleton
static <T> CloseableIterator<T> singleton(T theElem)
-
concat
@MustBeClosed static <T> CloseableIterator<T> concat(java.lang.Iterable<? extends CloseableIterator<T>> theIters)
-
concat
static <T> CloseableIterator<T> concat(java.util.Iterator<? extends CloseableIterator<T>> inputs)
-
first
static <T> java.util.Optional<T> first(CloseableIterator<T> theIter)
Get the first element in the iterator. The iterator is closed after collection.- Parameters:
theIter
- the iterator- Returns:
- the first element in the iterator, or empty if none.
-
toSet
static <T> java.util.Set<T> toSet(CloseableIterator<T> theIter)
Collect the contents of the iterator as aSet
. The iterator is closed after collection.- Parameters:
theIter
- the iterator- Returns:
- the contents of the iterator as a Set.
-
toList
static <T> java.util.List<T> toList(CloseableIterator<T> theIter)
Collect the contents of the iterator as aList
. The iterator is closed after collection.- Parameters:
theIter
- the iterator- Returns:
- the contents of the iterator as a list.
-
collect
static <T,A,R> R collect(CloseableIterator<T> theIter, java.util.stream.Collector<T,A,R> theCollector)
Collect the contents of the iterator. The iterator is closed after collection.- Parameters:
theIter
- the iterator whose contents should be collectedtheCollector
- the colector- Returns:
- the collected object
-
size
static <T> long size(CloseableIterator<T> theIter)
Return the number of elements in the iterator. The iterator is closed after collection.- Parameters:
theIter
- the iterator- Returns:
- the number of elements in the Iterator
-
offset
@MustBeClosed static <T> CloseableIterator<T> offset(CloseableIterator<T> theIter, long theOffset)
-
limit
@MustBeClosed static <T> CloseableIterator<T> limit(CloseableIterator<T> theIter, long theLimit)
-
filter
@MustBeClosed static <T> CloseableIterator<T> filter(CloseableIterator<T> theIter, java.util.function.Predicate<T> thePredicate)
-
transform
@MustBeClosed static <In,Out> CloseableIterator<Out> transform(CloseableIterator<In> theIter, java.util.function.Function<In,Out> theFunction)
-
toCloseable
@MustBeClosed static <T> CloseableIterator<T> toCloseable(java.util.stream.Stream<T> theStream)
-
toCloseable
static <T> CloseableIterator<T> toCloseable(java.util.Iterator<? extends T> theIterator)
-
toCloseable
@MustBeClosed static <T> CloseableIterator<T> toCloseable(java.util.Iterator<? extends T> theIterator, java.lang.Runnable theOnClose)
-
isEmpty
static boolean isEmpty(CloseableIterator<?> theIterator)
-
map
static <I,O> CloseableIterator<O> map(CloseableIterator<I> theIterator, java.util.function.Function<? super I,O> theFunction)
-
concat
static <I> CloseableIterator<I> concat(CloseableIterator<I> theFirst, CloseableIterator<I> theSecond)
-
-