E - data typepublic class ImmutableList<E> extends Object implements List<E>, Cloneable, Serializable
List implementation that doesn't allow any data modifications to be done.
Unlike Collections.unmodifiableList(List) this implementation keeps list data copy.
If you need to provide an unmodifiable reference for your list use Collections implementation.| Constructor and Description |
|---|
ImmutableList(Collection<? extends E> collection)
Constructs new
ImmutableList based on the specified Collection. |
ImmutableList(E... data)
Constructs new
ImmutableList based on the specified list data. |
| Modifier and Type | Method and Description |
|---|---|
boolean |
add(E element) |
void |
add(int index,
E element) |
boolean |
addAll(Collection<? extends E> collection) |
boolean |
addAll(int index,
Collection<? extends E> c) |
void |
clear() |
boolean |
contains(Object element) |
boolean |
containsAll(Collection<?> collection) |
protected UnsupportedOperationException |
createModificationException()
Returns new
UnsupportedOperationException instance specific for this implementation. |
boolean |
equals(Object o) |
E |
get(int index) |
int |
hashCode() |
int |
indexOf(Object o) |
boolean |
isEmpty() |
Iterator<E> |
iterator() |
int |
lastIndexOf(Object o) |
ListIterator<E> |
listIterator() |
ListIterator<E> |
listIterator(int index) |
E |
remove(int index) |
boolean |
remove(Object element) |
boolean |
removeAll(Collection<?> collection) |
boolean |
retainAll(Collection<?> collection) |
E |
set(int index,
E element) |
int |
size() |
List<E> |
subList(int fromIndex,
int toIndex) |
Object[] |
toArray() |
<T> T[] |
toArray(T[] array) |
String |
toString() |
clone, finalize, getClass, notify, notifyAll, wait, wait, waitreplaceAll, sort, spliteratorparallelStream, removeIf, streampublic ImmutableList(@NotNull E... data)
ImmutableList based on the specified list data.data - data arraypublic ImmutableList(@NotNull Collection<? extends E> collection)
ImmutableList based on the specified Collection.collection - data Collectionpublic int size()
public boolean isEmpty()
public boolean containsAll(@NotNull Collection<?> collection)
containsAll in interface Collection<E>containsAll in interface List<E>public boolean addAll(@NotNull Collection<? extends E> collection)
public boolean removeAll(@NotNull Collection<?> collection)
public boolean retainAll(@NotNull Collection<?> collection)
public void clear()
public int lastIndexOf(@Nullable Object o)
lastIndexOf in interface List<E>public boolean addAll(int index,
@NotNull
Collection<? extends E> c)
@NotNull public ListIterator<E> listIterator()
listIterator in interface List<E>@NotNull public ListIterator<E> listIterator(int index)
listIterator in interface List<E>@NotNull protected UnsupportedOperationException createModificationException()
UnsupportedOperationException instance specific for this implementation.UnsupportedOperationException instance specific for this implementationpublic int hashCode()
Copyright © 2020. All rights reserved.