@GwtCompatible(emulated=true)
public abstract class ImmutableCollection<E>
extends java.lang.Object
implements java.util.Collection<E>, java.io.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.Builder<E>
Abstract base class for builders of
ImmutableCollection types. |
| Modifier and Type | Method and Description |
|---|---|
boolean |
add(E e)
Deprecated.
Unsupported operation.
|
boolean |
addAll(java.util.Collection<? extends E> newElements)
Deprecated.
Unsupported operation.
|
ImmutableList<E> |
asList()
Returns a list view of the collection.
|
void |
clear()
Deprecated.
Unsupported operation.
|
boolean |
contains(java.lang.Object object) |
boolean |
containsAll(java.util.Collection<?> targets) |
boolean |
isEmpty() |
abstract UnmodifiableIterator<E> |
iterator()
Returns an unmodifiable iterator across the elements in this collection.
|
boolean |
remove(java.lang.Object object)
Deprecated.
Unsupported operation.
|
boolean |
removeAll(java.util.Collection<?> oldElements)
Deprecated.
Unsupported operation.
|
boolean |
retainAll(java.util.Collection<?> elementsToKeep)
Deprecated.
Unsupported operation.
|
java.lang.Object[] |
toArray() |
<T> T[] |
toArray(T[] other) |
java.lang.String |
toString() |
public abstract UnmodifiableIterator<E> iterator()
public java.lang.Object[] toArray()
toArray in interface java.util.Collection<E>public <T> T[] toArray(T[] other)
toArray in interface java.util.Collection<E>public boolean contains(@Nullable
java.lang.Object object)
contains in interface java.util.Collection<E>public boolean containsAll(java.util.Collection<?> targets)
containsAll in interface java.util.Collection<E>public boolean isEmpty()
isEmpty in interface java.util.Collection<E>public java.lang.String toString()
toString in class java.lang.Object@Deprecated public final boolean add(E e)
add in interface java.util.Collection<E>java.lang.UnsupportedOperationException - always@Deprecated public final boolean remove(java.lang.Object object)
remove in interface java.util.Collection<E>java.lang.UnsupportedOperationException - always@Deprecated public final boolean addAll(java.util.Collection<? extends E> newElements)
addAll in interface java.util.Collection<E>java.lang.UnsupportedOperationException - always@Deprecated public final boolean removeAll(java.util.Collection<?> oldElements)
removeAll in interface java.util.Collection<E>java.lang.UnsupportedOperationException - always@Deprecated public final boolean retainAll(java.util.Collection<?> elementsToKeep)
retainAll in interface java.util.Collection<E>java.lang.UnsupportedOperationException - always@Deprecated public final void clear()
clear in interface java.util.Collection<E>java.lang.UnsupportedOperationException - alwayspublic ImmutableList<E> asList()