Class ConverterIterator<I,O>

java.lang.Object
com.globalmentor.collections.iterators.ConverterIterator<I,O>
Type Parameters:
I - The input type.
O - The output type.
All Implemented Interfaces:
Iterator<O>
Direct Known Subclasses:
ConverterListIterator

public class ConverterIterator<I,O> extends Object implements Iterator<O>
An iterator that returns its objects converted using a Converter.
Author:
Garret Wilson
See Also:
  • Constructor Details

    • ConverterIterator

      public ConverterIterator(Iterator<I> iterator, Converter<I,O> converter)
      Iterator and converter constructor.
      Parameters:
      iterator - The iterator of source objects.
      converter - The conversor to be used on the iterable.
      Throws:
      NullPointerException - of if the given iterator and/or converter is null.
  • Method Details

    • getIterator

      protected Iterator<I> getIterator()
      Returns:
      The iterator this class decorates.
    • getConverter

      public Converter<I,O> getConverter()
      Returns:
      The converter for converting the elements.
    • hasNext

      public boolean hasNext()
      Specified by:
      hasNext in interface Iterator<I>
    • next

      public O next()

      This implementation converts the next object before returning it.

      Specified by:
      next in interface Iterator<I>
      See Also:
    • remove

      public void remove()
      Specified by:
      remove in interface Iterator<I>