Class ConverterListIterator<I,​O>

  • Type Parameters:
    I - The input type.
    O - The output type.
    All Implemented Interfaces:
    java.util.Iterator<O>, java.util.ListIterator<O>

    public class ConverterListIterator<I,​O>
    extends ConverterIterator<I,​O>
    implements java.util.ListIterator<O>
    A list iterator that returns its objects converted using a Converter.

    This implementation does not support adding or setting elements.

    Author:
    Garret Wilson
    See Also:
    Converter
    • Constructor Summary

      Constructors 
      Constructor Description
      ConverterListIterator​(java.util.ListIterator<I> iterator, Converter<I,​O> converter)
      Iterator and converter constructor.
    • Constructor Detail

      • ConverterListIterator

        public ConverterListIterator​(java.util.ListIterator<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:
        java.lang.NullPointerException - of if the given iterator and/or converter is null.
    • Method Detail

      • getIterator

        protected java.util.ListIterator<I> getIterator()
        This version returns the iterator as a ListIterator.
        Overrides:
        getIterator in class ConverterIterator<I,​O>
        Returns:
        The iterator this class decorates.
      • hasNext

        public boolean hasNext()
        Specified by:
        hasNext in interface java.util.Iterator<I>
        Specified by:
        hasNext in interface java.util.ListIterator<I>
        Overrides:
        hasNext in class ConverterIterator<I,​O>
      • next

        public O next()

        This implementation converts the next object before returning it.

        This implementation converts the next object before returning it.

        Specified by:
        next in interface java.util.Iterator<I>
        Specified by:
        next in interface java.util.ListIterator<I>
        Overrides:
        next in class ConverterIterator<I,​O>
        See Also:
        Converter.convert(Object)
      • hasPrevious

        public boolean hasPrevious()
        Specified by:
        hasPrevious in interface java.util.ListIterator<I>
      • previous

        public O previous()

        This implementation converts the previous object before returning it.

        Specified by:
        previous in interface java.util.ListIterator<I>
        See Also:
        Converter.convert(Object)
      • nextIndex

        public int nextIndex()
        Specified by:
        nextIndex in interface java.util.ListIterator<I>
      • previousIndex

        public int previousIndex()
        Specified by:
        previousIndex in interface java.util.ListIterator<I>
      • set

        public void set​(O e)

        This implementation throws an UnsupportedOperationException.

        Specified by:
        set in interface java.util.ListIterator<I>
      • add

        public void add​(O e)

        This implementation throws an UnsupportedOperationException.

        Specified by:
        add in interface java.util.ListIterator<I>