com.google.common.collect
Class ImmutableCollection<E>

java.lang.Object
  extended by 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.lang.Object
implements java.util.Collection<E>, java.io.Serializable

An immutable collection. Does not permit null elements.

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.

Since:
2.0 (imported from Google Collections Library)
See Also:
Serialized Form

Nested Class Summary
static class ImmutableCollection.Builder<E>
          Abstract base class for builders of ImmutableCollection types.
 
Method Summary
 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()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.Collection
equals, hashCode, size
 

Method Detail

iterator

public abstract UnmodifiableIterator<E> iterator()
Returns an unmodifiable iterator across the elements in this collection.

Specified by:
iterator in interface java.lang.Iterable<E>
Specified by:
iterator in interface java.util.Collection<E>

toArray

public java.lang.Object[] toArray()
Specified by:
toArray in interface java.util.Collection<E>

toArray

public <T> T[] toArray(T[] other)
Specified by:
toArray in interface java.util.Collection<E>

contains

public boolean contains(@Nullable
                        java.lang.Object object)
Specified by:
contains in interface java.util.Collection<E>

containsAll

public boolean containsAll(java.util.Collection<?> targets)
Specified by:
containsAll in interface java.util.Collection<E>

isEmpty

public boolean isEmpty()
Specified by:
isEmpty in interface java.util.Collection<E>

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

add

@Deprecated
public final boolean add(E e)
Deprecated. Unsupported operation.

Guaranteed to throw an exception and leave the collection unmodified.

Specified by:
add in interface java.util.Collection<E>
Throws:
java.lang.UnsupportedOperationException - always

remove

@Deprecated
public final boolean remove(java.lang.Object object)
Deprecated. Unsupported operation.

Guaranteed to throw an exception and leave the collection unmodified.

Specified by:
remove in interface java.util.Collection<E>
Throws:
java.lang.UnsupportedOperationException - always

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.

Specified by:
addAll in interface java.util.Collection<E>
Throws:
java.lang.UnsupportedOperationException - always

removeAll

@Deprecated
public final boolean removeAll(java.util.Collection<?> oldElements)
Deprecated. Unsupported operation.

Guaranteed to throw an exception and leave the collection unmodified.

Specified by:
removeAll in interface java.util.Collection<E>
Throws:
java.lang.UnsupportedOperationException - always

retainAll

@Deprecated
public final boolean retainAll(java.util.Collection<?> elementsToKeep)
Deprecated. Unsupported operation.

Guaranteed to throw an exception and leave the collection unmodified.

Specified by:
retainAll in interface java.util.Collection<E>
Throws:
java.lang.UnsupportedOperationException - always

clear

@Deprecated
public final void clear()
Deprecated. Unsupported operation.

Guaranteed to throw an exception and leave the collection unmodified.

Specified by:
clear in interface java.util.Collection<E>
Throws:
java.lang.UnsupportedOperationException - always

asList

public ImmutableList<E> asList()
Returns a list view of the collection.

Since:
2.0