public final class UnmodifiableList<E> extends AbstractSerializableListDecorator<E> implements Unmodifiable
List
to ensure it can't be altered.
This class is Serializable from Commons Collections 3.1.
Attempts to modify it will result in an UnsupportedOperationException.
Constructor and Description |
---|
UnmodifiableList(List<? extends E> list)
Constructor that wraps (not copies).
|
Modifier and Type | Method and Description |
---|---|
void |
add(int index,
E object) |
boolean |
add(Object object) |
boolean |
addAll(Collection<? extends E> coll) |
boolean |
addAll(int index,
Collection<? extends E> coll) |
void |
clear() |
Iterator<E> |
iterator() |
ListIterator<E> |
listIterator() |
ListIterator<E> |
listIterator(int index) |
E |
remove(int index) |
boolean |
remove(Object object) |
boolean |
removeAll(Collection<?> coll) |
boolean |
removeIf(Predicate<? super E> filter) |
boolean |
retainAll(Collection<?> coll) |
E |
set(int index,
E object) |
List<E> |
subList(int fromIndex,
int toIndex) |
static <E> List<E> |
unmodifiableList(List<? extends E> list)
Factory method to create an unmodifiable list.
|
decorated, equals, get, hashCode, indexOf, lastIndexOf
contains, containsAll, isEmpty, setCollection, size, toArray, toArray, toString
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
contains, containsAll, isEmpty, replaceAll, size, sort, spliterator, toArray, toArray
parallelStream, stream
public UnmodifiableList(List<? extends E> list)
list
- the list to decorate, must not be nullNullPointerException
- if list is nullpublic static <E> List<E> unmodifiableList(List<? extends E> list)
E
- the type of the elements in the listlist
- the list to decorate, must not be nullNullPointerException
- if list is nullpublic boolean add(Object object)
add
in interface Collection<E>
add
in interface List<E>
add
in class AbstractCollectionDecorator<E>
public boolean addAll(Collection<? extends E> coll)
addAll
in interface Collection<E>
addAll
in interface List<E>
addAll
in class AbstractCollectionDecorator<E>
public void clear()
clear
in interface Collection<E>
clear
in interface List<E>
clear
in class AbstractCollectionDecorator<E>
public boolean remove(Object object)
remove
in interface Collection<E>
remove
in interface List<E>
remove
in class AbstractCollectionDecorator<E>
public boolean removeIf(Predicate<? super E> filter)
removeIf
in interface Collection<E>
removeIf
in class AbstractCollectionDecorator<E>
public boolean removeAll(Collection<?> coll)
removeAll
in interface Collection<E>
removeAll
in interface List<E>
removeAll
in class AbstractCollectionDecorator<E>
public boolean retainAll(Collection<?> coll)
retainAll
in interface Collection<E>
retainAll
in interface List<E>
retainAll
in class AbstractCollectionDecorator<E>
public ListIterator<E> listIterator()
listIterator
in interface List<E>
listIterator
in class AbstractListDecorator<E>
public ListIterator<E> listIterator(int index)
listIterator
in interface List<E>
listIterator
in class AbstractListDecorator<E>
public void add(int index, E object)
public boolean addAll(int index, Collection<? extends E> coll)
public E remove(int index)
Copyright © 2006–2022 Apache Software Foundation. All rights reserved.