Class NiceIterator<T>

All Implemented Interfaces:
Iterator<T>, org.apache.jena.atlas.iterator.IteratorCloseable<T>, org.apache.jena.atlas.lib.Closeable, ClosableIterator<T>, ExtendedIterator<T>
Direct Known Subclasses:
ContNodeIteratorImpl, IteratorOfJenaSets, LazyIterator, Map1Iterator, MapFilterIterator, NullIterator, ObjectIterator, RoaringBitmapTripleIterator, SeqNodeIteratorImpl, SingletonIterator, SparseArrayIterator, WrappedIterator

public class NiceIterator<T> extends Object implements ExtendedIterator<T>
NiceIterator is the standard base class implementing ExtendedIterator. It provides the static methods for andThen, filterKeep and filterDrop; these can be reused from any other class. It defines equivalent instance methods for descendants and to satisfy ExtendedIterator.
  • Constructor Details

    • NiceIterator

      public NiceIterator()
  • Method Details

    • close

      public void close()
      default close: don't need to do anything.
      Specified by:
      close in interface ClosableIterator<T>
      Specified by:
      close in interface org.apache.jena.atlas.lib.Closeable
    • hasNext

      public boolean hasNext()
      default hasNext: no elements, return false.
      Specified by:
      hasNext in interface Iterator<T>
    • next

      public T next()
      default next: throw an exception.
      Specified by:
      next in interface Iterator<T>
    • remove

      public void remove()
      default remove: we have no elements, so we can't remove any.
      Specified by:
      remove in interface Iterator<T>
    • removeNext

      public T removeNext()
      Answer the next object, and remove it.
      Specified by:
      removeNext in interface ExtendedIterator<T>
    • andThen

      public static <T> ExtendedIterator<T> andThen(Iterator<T> a, Iterator<? extends T> b)
      concatenate two closable iterators.
    • andThen

      public <X extends T> ExtendedIterator<T> andThen(Iterator<X> other)
      make a new iterator, which is us then the other chap.
      Specified by:
      andThen in interface ExtendedIterator<T>
    • filterKeep

      public FilterIterator<T> filterKeep(Predicate<T> f)
      make a new iterator, which is our elements that pass the filter
      Specified by:
      filterKeep in interface ExtendedIterator<T>
    • filterDrop

      public FilterIterator<T> filterDrop(Predicate<T> f)
      make a new iterator, which is our elements that do not pass the filter
      Specified by:
      filterDrop in interface ExtendedIterator<T>
    • mapWith

      public <U> ExtendedIterator<U> mapWith(Function<T,U> map1)
      make a new iterator which is the elementwise _map1_ of the base iterator.
      Specified by:
      mapWith in interface ExtendedIterator<T>
    • close

      public static void close(Iterator<?> it)
      If it is Closeable, close it.
    • emptyIterator

      public static <T> ExtendedIterator<T> emptyIterator()
      An iterator over no elements.
      A class singleton which doesn't iterate.
    • toList

      public List<T> toList()
      Answer a list of the elements in order, consuming this iterator.
      Specified by:
      toList in interface ExtendedIterator<T>
    • toSet

      public Set<T> toSet()
      Answer a list of the elements in order, consuming this iterator.
      Specified by:
      toSet in interface ExtendedIterator<T>
    • asSet

      public static <T> Set<T> asSet(ExtendedIterator<T> it)
      Answer a list of the elements of it in order, consuming this iterator. Canonical implementation of toSet().
    • asList

      public static <T> List<T> asList(ExtendedIterator<T> it)
      Answer a list of the elements from it, in order, consuming that iterator. Canonical implementation of toList().