Class TransformingList<FROM,​TO>

  • Type Parameters:
    FROM - the type to convert from
    TO - the type to convert to
    All Implemented Interfaces:
    java.lang.Iterable<TO>, java.util.Collection<TO>, java.util.List<TO>

    final class TransformingList<FROM,​TO>
    extends java.util.AbstractList<TO>
    Converts elements of one list to a different type on demand.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private java.util.List<? extends FROM> source
      The list to transform.
      private java.util.function.Function<? super FROM,​? extends TO> transform
      Converts elements to the new type.
      • Fields inherited from class java.util.AbstractList

        modCount
    • Constructor Summary

      Constructors 
      Constructor Description
      TransformingList​(java.util.List<? extends FROM> source, java.util.function.Function<? super FROM,​? extends TO> transform)
      Creates a new TransformingList.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      TO get​(int index)  
      int size()  
      • Methods inherited from class java.util.AbstractList

        add, add, addAll, clear, equals, hashCode, indexOf, iterator, lastIndexOf, listIterator, listIterator, remove, removeRange, set, subList
      • Methods inherited from class java.util.AbstractCollection

        addAll, contains, containsAll, isEmpty, remove, removeAll, retainAll, toArray, toArray, toString
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, wait, wait, wait
      • Methods inherited from interface java.util.Collection

        parallelStream, removeIf, stream
      • Methods inherited from interface java.lang.Iterable

        forEach
      • Methods inherited from interface java.util.List

        addAll, contains, containsAll, isEmpty, remove, removeAll, replaceAll, retainAll, sort, spliterator, toArray, toArray
    • Field Detail

      • source

        private final java.util.List<? extends FROM> source
        The list to transform.
      • transform

        private final java.util.function.Function<? super FROM,​? extends TO> transform
        Converts elements to the new type.
    • Constructor Detail

      • TransformingList

        TransformingList​(java.util.List<? extends FROM> source,
                         java.util.function.Function<? super FROM,​? extends TO> transform)
        Creates a new TransformingList.
        Parameters:
        source - the list to transform
        transform - transforms elements to the output type
    • Method Detail

      • get

        public TO get​(int index)
        Specified by:
        get in interface java.util.List<FROM>
        Specified by:
        get in class java.util.AbstractList<TO>
      • size

        public int size()
        Specified by:
        size in interface java.util.Collection<FROM>
        Specified by:
        size in interface java.util.List<FROM>
        Specified by:
        size in class java.util.AbstractCollection<TO>