@GwtCompatible(emulated=true) public abstract class ImmutableCollection<E> extends AbstractCollection<E> implements Serializable
In addition to the Collection methods, this class has an asList() method, which returns a list view of the collection's elements.
Note: Although this class is not final, it cannot be subclassed outside of this package as it has no public or protected constructors. Thus, instances of this type are guaranteed to be immutable.
| Modifier and Type | Class and Description |
|---|---|
static class |
ImmutableCollection
Abstract base class for builders of
ImmutableCollection types.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
add(E e)
Deprecated.
Unsupported operation.
|
boolean |
addAll(Collection
Deprecated.
Unsupported operation.
|
ImmutableList |
asList()
Returns a list view of the collection.
|
void |
clear()
Deprecated.
Unsupported operation.
|
boolean |
contains(Object
|
abstract UnmodifiableIterator |
iterator()
Returns an unmodifiable iterator across the elements in this collection.
|
boolean |
remove(Object
Deprecated.
Unsupported operation.
|
boolean |
removeAll(Collection
Deprecated.
Unsupported operation.
|
boolean |
retainAll(Collection
Deprecated.
Unsupported operation.
|
Object |
toArray()
|
<T> T[] |
toArray(T[] other)
|
containsAll, isEmpty, size, toStringclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitequals, hashCode, parallelStream, removeIf, spliterator, streampublic abstract UnmodifiableIterator<E> iterator()
public final Object[] toArray()
public final <T> T[] toArray(T[] other)
public boolean contains(Objectobject)
@Deprecated public final boolean add(E e)
add in interface
Collection<E>
add in class
AbstractCollection<E>
UnsupportedOperationException - always
@Deprecated public final boolean remove(Objectobject)
remove in interface
Collection<E>
remove in class
AbstractCollection<E>
UnsupportedOperationException - always
@Deprecated public final boolean addAll(Collection<? extends E> newElements)
addAll in interface
Collection<E>
addAll in class
AbstractCollection<E>
UnsupportedOperationException - always
@Deprecated public final boolean removeAll(Collection<?> oldElements)
removeAll in interface
Collection<E>
removeAll in class
AbstractCollection<E>
UnsupportedOperationException - always
@Deprecated public final boolean retainAll(Collection<?> elementsToKeep)
retainAll in interface
Collection<E>
retainAll in class
AbstractCollection<E>
UnsupportedOperationException - always
@Deprecated public final void clear()
clear in interface
Collection<E>
clear in class
AbstractCollection<E>
UnsupportedOperationException - always
public ImmutableList<E> asList()