@GwtCompatible(emulated=true) public abstract class ImmutableCollection<E> extends java.util.AbstractCollection<E> implements 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 |
---|---|
(package private) static class |
ImmutableCollection.ArrayBasedBuilder<E> |
static class |
ImmutableCollection.Builder<E>
Abstract base class for builders of
ImmutableCollection types. |
Modifier and Type | Field and Description |
---|---|
private ImmutableList<E> |
asList |
Constructor and Description |
---|
ImmutableCollection() |
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) |
(package private) int |
copyIntoArray(java.lang.Object[] dst,
int offset)
Copies the contents of this immutable collection into the specified array at the specified
offset.
|
(package private) ImmutableList<E> |
createAsList() |
(package private) abstract boolean |
isPartialView()
Returns
true if this immutable collection's implementation contains references to
user-created objects that aren't accessible via this collection's methods. |
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) |
(package private) java.lang.Object |
writeReplace() |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
private transient ImmutableList<E> asList
public abstract UnmodifiableIterator<E> iterator()
public final java.lang.Object[] toArray()
public final <T> T[] toArray(T[] other)
public boolean contains(@Nullable java.lang.Object object)
@Deprecated public final boolean add(E e)
@Deprecated public final boolean remove(java.lang.Object object)
@Deprecated public final boolean addAll(java.util.Collection<? extends E> newElements)
@Deprecated public final boolean removeAll(java.util.Collection<?> oldElements)
@Deprecated public final boolean retainAll(java.util.Collection<?> elementsToKeep)
@Deprecated public final void clear()
public ImmutableList<E> asList()
ImmutableList<E> createAsList()
abstract boolean isPartialView()
true
if this immutable collection's implementation contains references to
user-created objects that aren't accessible via this collection's methods. This is generally
used to determine whether copyOf
implementations should make an explicit copy to avoid
memory leaks.int copyIntoArray(java.lang.Object[] dst, int offset)
offset + size()
.java.lang.Object writeReplace()