Package org.apache.jena.util.iterator
Interface ExtendedIterator<T>
-
- Type Parameters:
T
- the type of element over which an instance of ExtendedIterator iterates
- All Superinterfaces:
ClosableIterator<T>
,Closeable
,java.util.Iterator<T>
,IteratorCloseable<T>
- All Known Subinterfaces:
NodeIterator
,NsIterator
,ResIterator
,RSIterator
,StmtIterator
,TripleIterator
- All Known Implementing Classes:
ContNodeIteratorImpl
,FilterIterator
,LazyIterator
,Map1Iterator
,MapFilterIterator
,NiceIterator
,NodeIteratorImpl
,NsIteratorImpl
,NullIterator
,ObjectIterator
,RandomOrderIterator
,ResIteratorImpl
,RSIteratorImpl
,SeqNodeIteratorImpl
,SingletonIterator
,StmtIteratorImpl
,StoreTripleIterator
,TrackingTripleIterator
,WrappedIterator
public interface ExtendedIterator<T> extends ClosableIterator<T>
An ExtendedIterator is aClosableIterator
on which other operations are defined for convenience in iterator composition: composition, filtering in, filtering out, and element mapping.
NOTE that the result of these operations consumes the base iterator(s); they do not make independent copies.
The canonical implementation of ExtendedIterator isNiceIterator
, which also defines static methods for these operations that will work on anyClosableIterator
s.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description <X extends T>
ExtendedIterator<T>andThen(java.util.Iterator<X> other)
return a new iterator which delivers all the elements of this iterator and then all the elements of the other iterator.ExtendedIterator<T>
filterDrop(java.util.function.Predicate<T> f)
return a new iterator containing only the elements of _this_ which are rejected by the filter _f_.ExtendedIterator<T>
filterKeep(java.util.function.Predicate<T> f)
return a new iterator containing only the elements of _this_ which pass the filter _f_.default void
forEach(java.util.function.Consumer<T> action)
Execute an action on each element of the iterator.<U> ExtendedIterator<U>
mapWith(java.util.function.Function<T,U> map1)
return a new iterator where each element is the result of applying _map1_ to the corresponding element of _this_.default java.util.Optional<T>
nextOptional()
Answer with anOptional
.T
removeNext()
Answer the next object, and remove it.java.util.List<T>
toList()
Answer a list of the [remaining] elements of this iterator, in order, consuming this iterator.java.util.Set<T>
toSet()
Answer a set of the [remaining] elements of this iterator, consuming this iterator.-
Methods inherited from interface org.apache.jena.util.iterator.ClosableIterator
close
-
-
-
-
Method Detail
-
removeNext
T removeNext()
Answer the next object, and remove it. Equivalent to next(); remove().
-
andThen
<X extends T> ExtendedIterator<T> andThen(java.util.Iterator<X> other)
return a new iterator which delivers all the elements of this iterator and then all the elements of the other iterator. Does not copy either iterator; they are consumed as the result iterator is consumed.
-
filterKeep
ExtendedIterator<T> filterKeep(java.util.function.Predicate<T> f)
return a new iterator containing only the elements of _this_ which pass the filter _f_. The order of the elements is preserved. Does not copy _this_, which is consumed as the result is consumed.
-
filterDrop
ExtendedIterator<T> filterDrop(java.util.function.Predicate<T> f)
return a new iterator containing only the elements of _this_ which are rejected by the filter _f_. The order of the elements is preserved. Does not copy _this_, which is consumed as the result is consumed.
-
mapWith
<U> ExtendedIterator<U> mapWith(java.util.function.Function<T,U> map1)
return a new iterator where each element is the result of applying _map1_ to the corresponding element of _this_. _this_ is not copied; it is consumed as the result is consumed.
-
forEach
default void forEach(java.util.function.Consumer<T> action)
Execute an action on each element of the iterator. This operation ends and closes theExtendedIterator
even if there is an exception. Shorter name for "Iterator.forEachRemaining
", adding exception handling.
-
toList
java.util.List<T> toList()
Answer a list of the [remaining] elements of this iterator, in order, consuming this iterator.
-
toSet
java.util.Set<T> toSet()
Answer a set of the [remaining] elements of this iterator, consuming this iterator.
-
nextOptional
default java.util.Optional<T> nextOptional()
Answer with anOptional
. This operation assumes that theExtendedIterator
does not return null fornext()
. If it does,NullPointerException
is thrown.- If there is no next, return
Optional.empty()
- If the next object exists, and is not null, return that in the
Optional
. - If the next object exists, and is null, throw
NullPointerException
- If there is no next, return
-
-