Class CompositeList<T>

  • Type Parameters:
    T - Element type
    All Implemented Interfaces:
    java.lang.Iterable<T>, java.util.Collection<T>, java.util.List<T>

    public class CompositeList<T>
    extends java.util.AbstractList<T>
    Read-only list that is the concatenation of sub-lists.

    The list is read-only; attempts to call methods such as AbstractList.add(Object) or AbstractList.set(int, Object) will throw.

    Changes to the backing lists, including changes in length, will be reflected in this list.

    This class is not thread-safe. Changes to backing lists will cause unspecified behavior.

    • Field Summary

      Fields 
      Modifier and Type Field Description
      private com.google.common.collect.ImmutableList<java.util.List<T>> lists  
      • Fields inherited from class java.util.AbstractList

        modCount
    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      private CompositeList​(com.google.common.collect.ImmutableList<java.util.List<T>> lists)
      Creates a CompositeList.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      T get​(int index)  
      static <T> java.util.List<T> of()
      Creates a CompositeList of zero lists.
      static <T> CompositeList<T> of​(java.util.List<? extends T>... lists)
      Creates a CompositeList.
      static <T> CompositeList<T> of​(java.util.List<? extends T> list0, java.util.List<? extends T> list1)
      Creates a CompositeList of two lists.
      static <T> CompositeList<T> of​(java.util.List<? extends T> list0, java.util.List<? extends T> list1, java.util.List<? extends T> list2)
      Creates a CompositeList of three lists.
      static <T> java.util.List<T> of​(java.util.List<T> list0)
      Creates a CompositeList of one list.
      static <T> CompositeList<T> ofCopy​(java.lang.Iterable<java.util.List<T>> lists)
      Creates a CompositeList.
      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, toArray
      • 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

      • lists

        private final com.google.common.collect.ImmutableList<java.util.List<T>> lists
    • Constructor Detail

      • CompositeList

        private CompositeList​(com.google.common.collect.ImmutableList<java.util.List<T>> lists)
        Creates a CompositeList.
        Parameters:
        lists - Constituent lists
    • Method Detail

      • of

        @SafeVarargs
        public static <T> CompositeList<T> of​(java.util.List<? extends T>... lists)
        Creates a CompositeList.
        Type Parameters:
        T - Element type
        Parameters:
        lists - Constituent lists
        Returns:
        List consisting of all lists
      • ofCopy

        public static <T> CompositeList<T> ofCopy​(java.lang.Iterable<java.util.List<T>> lists)
        Creates a CompositeList.
        Type Parameters:
        T - Element type
        Parameters:
        lists - Constituent lists
        Returns:
        List consisting of all lists
      • of

        public static <T> java.util.List<T> of()
        Creates a CompositeList of zero lists.
        Type Parameters:
        T - Element type
        Returns:
        List consisting of all lists
      • of

        public static <T> java.util.List<T> of​(java.util.List<T> list0)
        Creates a CompositeList of one list.
        Type Parameters:
        T - Element type
        Parameters:
        list0 - List
        Returns:
        List consisting of all lists
      • of

        public static <T> CompositeList<T> of​(java.util.List<? extends T> list0,
                                              java.util.List<? extends T> list1)
        Creates a CompositeList of two lists.
        Type Parameters:
        T - Element type
        Parameters:
        list0 - First list
        list1 - Second list
        Returns:
        List consisting of all lists
      • of

        public static <T> CompositeList<T> of​(java.util.List<? extends T> list0,
                                              java.util.List<? extends T> list1,
                                              java.util.List<? extends T> list2)
        Creates a CompositeList of three lists.
        Type Parameters:
        T - Element type
        Parameters:
        list0 - First list
        list1 - Second list
        list2 - Third list
        Returns:
        List consisting of all lists
      • get

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

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