Class DerivedIterator<S,E>

java.lang.Object
org.apache.sis.util.collection.DerivedIterator<S,E>
Type Parameters:
S - the type of elements in the storage collection.
E - the type of elements in this set.
All Implemented Interfaces:
Iterator<E>

final class DerivedIterator<S,E> extends Object implements Iterator<E>
An iterator which performs conversions on the fly using the given converter. If a value is converted into a null value, then this iterator skips that value. Consequently, this iterator cannot return null value.
Since:
0.3
Version:
0.3
  • Field Details

    • iterator

      private final Iterator<S> iterator
      The original iterator to wrap.
    • converter

      private final ObjectConverter<S,E> converter
      The converter from the original values to the converted values.
    • next

      private transient E next
      The next element to be returned, or null.
  • Constructor Details

    • DerivedIterator

      DerivedIterator(Iterator<S> iterator, ObjectConverter<S,E> converter)
      Creates a new iterator wrapping the given original iterator and converting the values using the given converter.
  • Method Details

    • hasNext

      public boolean hasNext()
      Returns true if the iteration has more elements.
      Specified by:
      hasNext in interface Iterator<S>
    • next

      public E next()
      Returns the next element in the iteration.
      Specified by:
      next in interface Iterator<S>
    • remove

      public void remove()
      Removes from the underlying set the last element returned by the iterator.
      Specified by:
      remove in interface Iterator<S>
      Throws:
      UnsupportedOperationException - if the underlying collection doesn't supports the remove operation.