Class ImmutableList<E>

  • Type Parameters:
    E - the element type
    All Implemented Interfaces:
    Iterable<E>, Collection<E>, List<E>

    public abstract class ImmutableList<E>
    extends AbstractList<E>
    Weld's immutable List implementations. Based on the size of the data, methods of this class may return List instances using various storage strategies in order to achieve the best performance / memory consumption balance.
    Author:
    Jozef Hartinger
    • Method Detail

      • of

        @SafeVarargs
        public static <T> List<T> of​(T... elements)
        Creates an immutable list that consists of the given elements. This method should only be used in the varargs form. If there is a need to create an immutable list of an array of elements, copyOf(Object[]) should be used instead.
        Parameters:
        elements - the given elements
        Returns:
        an immutable list
      • copyOf

        public static <T> List<T> copyOf​(T[] elements)
        Creates an immutable list that consists of the elements in the given array. A copy of the given array is used which means that any modifications to the given array will not affect the immutable list.
        Parameters:
        elements - the given array of elements
        Returns:
        an immutable list
      • copyOf

        public static <T> List<T> copyOf​(Collection<T> source)
        Creates an immutable list that consists of the elements in the given collection. If the given collection is already an immutable list, it is returned directly.
        Parameters:
        source - the given collection
        Returns:
        an immutable list
      • copyOf

        public static <T> List<T> copyOf​(Iterable<T> source)
      • collector

        public static <T> org.jboss.weld.util.collections.ImmutableList.ImmutableListCollector<T> collector()
        Returns a collector that can be used to collect items of a stream into an immutable list.
        Returns:
        collector
      • builder

        public static <T> ImmutableList.Builder<T> builder()
        Creates a new empty builder for building immutable lists.
        Returns:
        a new empty builder
      • set

        public E set​(int index,
                     E element)
        Specified by:
        set in interface List<E>
        Overrides:
        set in class AbstractList<E>
      • add

        public void add​(int index,
                        E element)
        Specified by:
        add in interface List<E>
        Overrides:
        add in class AbstractList<E>
      • removeRange

        protected void removeRange​(int fromIndex,
                                   int toIndex)
        Overrides:
        removeRange in class AbstractList<E>
      • replaceAll

        public void replaceAll​(UnaryOperator<E> operator)
      • sort

        public void sort​(Comparator<? super E> c)
      • removeIf

        public boolean removeIf​(Predicate<? super E> filter)