Package com.google.common.collect
Class ImmutableCollection<E>
- java.lang.Object
-
- java.util.AbstractCollection<E>
-
- com.google.common.collect.ImmutableCollection<E>
-
- All Implemented Interfaces:
java.io.Serializable
,java.lang.Iterable<E>
,java.util.Collection<E>
- Direct Known Subclasses:
ImmutableList
,ImmutableMultiset
,ImmutableSet
@GwtCompatible(emulated=true) public abstract class ImmutableCollection<E> extends java.util.AbstractCollection<E> implements java.io.Serializable
An immutable collection. Does not permit null elements.In addition to the
Collection
methods, this class has anasList()
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.
- Since:
- 2.0 (imported from Google Collections Library)
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
ImmutableCollection.Builder<E>
Abstract base class for builders ofImmutableCollection
types.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods Modifier and Type Method 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)
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)
-
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
-
-
-
Method Detail
-
iterator
public abstract UnmodifiableIterator<E> iterator()
Returns an unmodifiable iterator across the elements in this collection.
-
toArray
public final java.lang.Object[] toArray()
-
toArray
public final <T> T[] toArray(T[] other)
-
contains
public boolean contains(@Nullable java.lang.Object object)
-
add
@Deprecated public final boolean add(E e)
Deprecated.Unsupported operation.Guaranteed to throw an exception and leave the collection unmodified.
-
remove
@Deprecated public final boolean remove(java.lang.Object object)
Deprecated.Unsupported operation.Guaranteed to throw an exception and leave the collection unmodified.
-
addAll
@Deprecated public final boolean addAll(java.util.Collection<? extends E> newElements)
Deprecated.Unsupported operation.Guaranteed to throw an exception and leave the collection unmodified.
-
removeAll
@Deprecated public final boolean removeAll(java.util.Collection<?> oldElements)
Deprecated.Unsupported operation.Guaranteed to throw an exception and leave the collection unmodified.
-
retainAll
@Deprecated public final boolean retainAll(java.util.Collection<?> elementsToKeep)
Deprecated.Unsupported operation.Guaranteed to throw an exception and leave the collection unmodified.
-
clear
@Deprecated public final void clear()
Deprecated.Unsupported operation.Guaranteed to throw an exception and leave the collection unmodified.
-
asList
public ImmutableList<E> asList()
Returns a list view of the collection.- Since:
- 2.0
-
-