Class UnmodifiableList<E>
- java.lang.Object
-
- org.apache.openjpa.lib.util.collections.AbstractCollectionDecorator<E>
-
- org.apache.openjpa.lib.util.collections.AbstractListDecorator<E>
-
- org.apache.openjpa.lib.util.collections.AbstractSerializableListDecorator<E>
-
- org.apache.openjpa.lib.util.collections.UnmodifiableList<E>
-
- All Implemented Interfaces:
Serializable,Iterable<E>,Collection<E>,List<E>,Unmodifiable
public final class UnmodifiableList<E> extends AbstractSerializableListDecorator<E> implements Unmodifiable
Decorates anotherListto ensure it can't be altered.This class is Serializable from Commons Collections 3.1.
Attempts to modify it will result in an UnsupportedOperationException.
- Since:
- 3.0
- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description UnmodifiableList(List<? extends E> list)Constructor that wraps (not copies).
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidadd(int index, E object)booleanadd(Object object)booleanaddAll(int index, Collection<? extends E> coll)booleanaddAll(Collection<? extends E> coll)voidclear()Iterator<E>iterator()ListIterator<E>listIterator()ListIterator<E>listIterator(int index)Eremove(int index)booleanremove(Object object)booleanremoveAll(Collection<?> coll)booleanremoveIf(Predicate<? super E> filter)booleanretainAll(Collection<?> coll)Eset(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.-
Methods inherited from class org.apache.openjpa.lib.util.collections.AbstractListDecorator
decorated, equals, get, hashCode, indexOf, lastIndexOf
-
Methods inherited from class org.apache.openjpa.lib.util.collections.AbstractCollectionDecorator
contains, containsAll, isEmpty, setCollection, size, 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, stream, toArray
-
Methods inherited from interface java.util.List
contains, containsAll, isEmpty, replaceAll, size, sort, spliterator, toArray, toArray
-
-
-
-
Constructor Detail
-
UnmodifiableList
public UnmodifiableList(List<? extends E> list)
Constructor that wraps (not copies).- Parameters:
list- the list to decorate, must not be null- Throws:
NullPointerException- if list is null
-
-
Method Detail
-
unmodifiableList
public static <E> List<E> unmodifiableList(List<? extends E> list)
Factory method to create an unmodifiable list.- Type Parameters:
E- the type of the elements in the list- Parameters:
list- the list to decorate, must not be null- Returns:
- a new unmodifiable list
- Throws:
NullPointerException- if list is null- Since:
- 4.0
-
add
public boolean add(Object object)
- Specified by:
addin interfaceCollection<E>- Specified by:
addin interfaceList<E>- Overrides:
addin classAbstractCollectionDecorator<E>
-
addAll
public boolean addAll(Collection<? extends E> coll)
- Specified by:
addAllin interfaceCollection<E>- Specified by:
addAllin interfaceList<E>- Overrides:
addAllin classAbstractCollectionDecorator<E>
-
clear
public void clear()
- Specified by:
clearin interfaceCollection<E>- Specified by:
clearin interfaceList<E>- Overrides:
clearin classAbstractCollectionDecorator<E>
-
remove
public boolean remove(Object object)
- Specified by:
removein interfaceCollection<E>- Specified by:
removein interfaceList<E>- Overrides:
removein classAbstractCollectionDecorator<E>
-
removeIf
public boolean removeIf(Predicate<? super E> filter)
- Specified by:
removeIfin interfaceCollection<E>- Overrides:
removeIfin classAbstractCollectionDecorator<E>- Since:
- 4.4
-
removeAll
public boolean removeAll(Collection<?> coll)
- Specified by:
removeAllin interfaceCollection<E>- Specified by:
removeAllin interfaceList<E>- Overrides:
removeAllin classAbstractCollectionDecorator<E>
-
retainAll
public boolean retainAll(Collection<?> coll)
- Specified by:
retainAllin interfaceCollection<E>- Specified by:
retainAllin interfaceList<E>- Overrides:
retainAllin classAbstractCollectionDecorator<E>
-
listIterator
public ListIterator<E> listIterator()
- Specified by:
listIteratorin interfaceList<E>- Overrides:
listIteratorin classAbstractListDecorator<E>
-
listIterator
public ListIterator<E> listIterator(int index)
- Specified by:
listIteratorin interfaceList<E>- Overrides:
listIteratorin classAbstractListDecorator<E>
-
add
public void add(int index, E object)
-
addAll
public boolean addAll(int index, Collection<? extends E> coll)
-
remove
public E remove(int index)
-
-