Class ConvertingIterator<S,​T>

  • All Implemented Interfaces:
    Iterator<T>

    public abstract class ConvertingIterator<S,​T>
    extends Object
    implements Iterator<T>
    An Iterator that converts an iterator over objects of type S (the source type) to an iterator over objects of type T (the target type).
    • Constructor Detail

      • ConvertingIterator

        protected ConvertingIterator​(Iterator<? extends S> iter)
        Creates a new ConvertingIterator that operates on the supplied source type itertor.
        Parameters:
        iter - The source type itertor for this ConvertingIterator, must not be null.
    • Method Detail

      • convert

        protected abstract T convert​(S sourceObject)
        Converts a source type object to a target type object.
      • hasNext

        public boolean hasNext()
        Checks whether the source type itertor contains more elements.
        Specified by:
        hasNext in interface Iterator<S>
        Returns:
        true if the source type itertor contains more elements, false otherwise.