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

java.lang.Object
  extended by com.google.common.collect.ImmutableCollection<E>
All Implemented Interfaces:
Serializable, Iterable<E>, Collection<E>
Direct Known Subclasses:
ImmutableList, ImmutableSet, ImmutableSortedSet

public abstract class ImmutableCollection<E>
extends Object
implements Collection<E>, Serializable

An immutable collection. Does not permit null 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.

Author:
Jesse Wilson
See Also:
Serialized Form

Method Summary
 boolean add(E e)
          Guaranteed to throw an exception and leave the collection unmodified.
 boolean addAll(Collection<? extends E> newElements)
          Guaranteed to throw an exception and leave the collection unmodified.
 void clear()
          Guaranteed to throw an exception and leave the collection unmodified.
 boolean contains(Object object)
           
 boolean containsAll(Collection<?> targets)
           
 boolean remove(Object object)
          Guaranteed to throw an exception and leave the collection unmodified.
 boolean removeAll(Collection<?> oldElements)
          Guaranteed to throw an exception and leave the collection unmodified.
 boolean retainAll(Collection<?> elementsToKeep)
          Guaranteed to throw an exception and leave the collection unmodified.
 Object[] toArray()
           
<T> T[]
toArray(T[] other)
           
 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, isEmpty, iterator, size
 

Method Detail

toArray

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

toArray

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

contains

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

containsAll

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

toString

public String toString()
Overrides:
toString in class Object

add

public final boolean add(E e)
Guaranteed to throw an exception and leave the collection unmodified.

Specified by:
add in interface Collection<E>
Throws:
UnsupportedOperationException - always

remove

public final boolean remove(Object object)
Guaranteed to throw an exception and leave the collection unmodified.

Specified by:
remove in interface Collection<E>
Throws:
UnsupportedOperationException - always

addAll

public final boolean addAll(Collection<? extends E> newElements)
Guaranteed to throw an exception and leave the collection unmodified.

Specified by:
addAll in interface Collection<E>
Throws:
UnsupportedOperationException - always

removeAll

public final boolean removeAll(Collection<?> oldElements)
Guaranteed to throw an exception and leave the collection unmodified.

Specified by:
removeAll in interface Collection<E>
Throws:
UnsupportedOperationException - always

retainAll

public final boolean retainAll(Collection<?> elementsToKeep)
Guaranteed to throw an exception and leave the collection unmodified.

Specified by:
retainAll in interface Collection<E>
Throws:
UnsupportedOperationException - always

clear

public final void clear()
Guaranteed to throw an exception and leave the collection unmodified.

Specified by:
clear in interface Collection<E>
Throws:
UnsupportedOperationException - always