@GwtCompatible(emulated=true) public abstract class ImmutableCollection<E> extends Object implements Collection<E>, 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(Collection<? extends E> newElements)
Deprecated.
Unsupported operation.
|
ImmutableList<E> |
asList()
Returns a list view of the collection.
|
void |
clear()
Deprecated.
Unsupported operation.
|
boolean |
contains(Object object) |
boolean |
containsAll(Collection<?> targets) |
boolean |
isEmpty() |
abstract UnmodifiableIterator<E> |
iterator()
Returns an unmodifiable iterator across the elements in this collection.
|
boolean |
remove(Object object)
Deprecated.
Unsupported operation.
|
boolean |
removeAll(Collection<?> oldElements)
Deprecated.
Unsupported operation.
|
boolean |
retainAll(Collection<?> elementsToKeep)
Deprecated.
Unsupported operation.
|
Object[] |
toArray() |
<T> T[] |
toArray(T[] other) |
String |
toString() |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
equals, hashCode, size
public abstract UnmodifiableIterator<E> iterator()
public Object[] toArray()
toArray
in interface Collection<E>
public <T> T[] toArray(T[] other)
toArray
in interface Collection<E>
public boolean contains(@Nullable Object object)
contains
in interface Collection<E>
public boolean containsAll(Collection<?> targets)
containsAll
in interface Collection<E>
public boolean isEmpty()
isEmpty
in interface Collection<E>
@Deprecated public final boolean add(E e)
add
in interface Collection<E>
UnsupportedOperationException
- always@Deprecated public final boolean remove(Object object)
remove
in interface Collection<E>
UnsupportedOperationException
- always@Deprecated public final boolean addAll(Collection<? extends E> newElements)
addAll
in interface Collection<E>
UnsupportedOperationException
- always@Deprecated public final boolean removeAll(Collection<?> oldElements)
removeAll
in interface Collection<E>
UnsupportedOperationException
- always@Deprecated public final boolean retainAll(Collection<?> elementsToKeep)
retainAll
in interface Collection<E>
UnsupportedOperationException
- always@Deprecated public final void clear()
clear
in interface Collection<E>
UnsupportedOperationException
- alwayspublic ImmutableList<E> asList()
Copyright © 2010-2013. All Rights Reserved.