Class AbstractConverterCollection<S,​D>

  • Type Parameters:
    S - The type of element contained in the source collection.
    D - The type of element contained in the destination collection.
    All Implemented Interfaces:
    java.lang.Iterable<D>, java.util.Collection<D>

    public abstract class AbstractConverterCollection<S,​D>
    extends CollectionDecorator<D>
    A collection that provides access to another collection, automatically converting elements to objects possibly of a different type. The conversion is done on the fly as elements are requested, and not before.
    Author:
    Garret Wilson
    • Constructor Detail

      • AbstractConverterCollection

        public AbstractConverterCollection​(java.util.Collection<S> collection)
        Collection constructor.
        Parameters:
        collection - The collection the elements of which this collection should convert.
    • Method Detail

      • convert

        protected abstract D convert​(S source)
        Converts an object in the collection to another object.
        Parameters:
        source - The object to convert.
        Returns:
        The converted object.
      • iterator

        public java.util.Iterator<D> iterator()
        Specified by:
        iterator in interface java.util.Collection<S>
        Specified by:
        iterator in interface java.lang.Iterable<S>
        Overrides:
        iterator in class CollectionDecorator<D>
        Returns:
        A custom proxied iterator that will convert returned elements on the fly.