Package org.jboss.weld.util.collections
Class ImmutableList<E>
java.lang.Object
java.util.AbstractCollection<E>
java.util.AbstractList<E>
org.jboss.weld.util.collections.ImmutableList<E>
- Type Parameters:
E- the element type
- All Implemented Interfaces:
Iterable<E>,Collection<E>,List<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
-
Nested Class Summary
Nested Classes -
Field Summary
Fields inherited from class java.util.AbstractList
modCount -
Method Summary
Modifier and TypeMethodDescriptionvoidbooleanbooleanaddAll(int index, Collection<? extends E> c) static <T> ImmutableList.Builder<T>builder()Creates a new empty builder for building immutable lists.voidclear()static <T> org.jboss.weld.util.collections.ImmutableList.ImmutableListCollector<T>Returns a collector that can be used to collect items of a stream into an immutable list.static <T> List<T>static <T> List<T>copyOf(Collection<T> source) Creates an immutable list that consists of the elements in the given collection.static <T> List<T>copyOf(T[] elements) Creates an immutable list that consists of the elements in the given array.protected IndexOutOfBoundsExceptionindexOutOfBoundsException(int index) booleanisEmpty()iterator()static <T> List<T>of(T... elements) Creates an immutable list that consists of the given elements.remove(int index) booleanprotected voidremoveRange(int fromIndex, int toIndex) voidreplaceAll(UnaryOperator<E> operator) voidsort(Comparator<? super E> c) Methods inherited from class java.util.AbstractList
equals, get, hashCode, indexOf, lastIndexOf, listIterator, subListMethods inherited from class java.util.AbstractCollection
addAll, contains, containsAll, remove, removeAll, retainAll, size, toArray, toArray, toStringMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.util.Collection
parallelStream, stream, toArray
-
Method Details
-
of
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
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
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
-
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
Creates a new empty builder for building immutable lists.- Returns:
- a new empty builder
-
add
- Specified by:
addin interfaceCollection<E>- Specified by:
addin interfaceList<E>- Overrides:
addin classAbstractList<E>
-
set
- Specified by:
setin interfaceList<E>- Overrides:
setin classAbstractList<E>
-
add
- Specified by:
addin interfaceList<E>- Overrides:
addin classAbstractList<E>
-
remove
- Specified by:
removein interfaceList<E>- Overrides:
removein classAbstractList<E>
-
clear
public void clear()- Specified by:
clearin interfaceCollection<E>- Specified by:
clearin interfaceList<E>- Overrides:
clearin classAbstractList<E>
-
addAll
- Specified by:
addAllin interfaceList<E>- Overrides:
addAllin classAbstractList<E>
-
removeRange
protected void removeRange(int fromIndex, int toIndex) - Overrides:
removeRangein classAbstractList<E>
-
isEmpty
public boolean isEmpty()- Specified by:
isEmptyin interfaceCollection<E>- Specified by:
isEmptyin interfaceList<E>- Overrides:
isEmptyin classAbstractCollection<E>
-
replaceAll
-
sort
-
removeIf
-
iterator
- Specified by:
iteratorin interfaceCollection<E>- Specified by:
iteratorin interfaceIterable<E>- Specified by:
iteratorin interfaceList<E>- Overrides:
iteratorin classAbstractList<E>
-
listIterator
- Specified by:
listIteratorin interfaceList<E>- Overrides:
listIteratorin classAbstractList<E>
-
spliterator
-
indexOutOfBoundsException
-