Class ConverterIterator<T1,​T2>

  • Type Parameters:
    T1 - type of input objects
    T2 - type of converted objects
    All Implemented Interfaces:
    java.util.Iterator<T2>

    public final class ConverterIterator<T1,​T2>
    extends java.lang.Object
    implements java.util.Iterator<T2>

    An Iterator that converts the objects of an existing iterator using a Converter.

    Iterator.remove() is not supported.

    Author:
    agz
    See Also:
    Converter
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean hasNext()  
      T2 next()  
      void remove()  
      java.lang.String toString()  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
      • Methods inherited from interface java.util.Iterator

        forEachRemaining
    • Constructor Detail

      • ConverterIterator

        public ConverterIterator​(java.util.Iterator<? extends T1> iterator,
                                 Converter<? super T1,​? extends T2> converter)
        Creates a new ConverterIterator, that converts the objects of the specified iterator using the specified Converter.

        The specified iterator must not be null.

        The specified converter must not be null.

        Parameters:
        iterator - underlying iterator whose iteration should be converted
        converter - Converter
    • Method Detail

      • hasNext

        public boolean hasNext()
        Specified by:
        hasNext in interface java.util.Iterator<T1>
      • next

        public T2 next()
        Specified by:
        next in interface java.util.Iterator<T1>
      • remove

        public void remove()
        Specified by:
        remove in interface java.util.Iterator<T1>
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object