Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

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

    java.lang.Object
      com.google.common.collect.ImmutableCollection<E>

All Implemented Interfaces:
  Serializable, Iterable<E>, Collection<E>

Direct Known Subclasses:
  ImmutableList, ImmutableMultiset, ImmutableSet

    @GwtCompatible(emulated=true)
    public abstract class ImmutableCollection<E>

extends Object
implements Collection<E>, 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)
Author:
  Jesse Wilson
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)` 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.
`ImmutableList<E>` | `asList()` Returns a list view of the collection.
`void` | `clear()` Guaranteed to throw an exception and leave the collection unmodified.
`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)` 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, size`

Method Detail

### iterator

    public abstract UnmodifiableIterator<E> iterator()

  Returns an unmodifiable iterator across the elements in this collection.

  Specified by:
    `iterator` in interface `Iterable<E>`
  Specified by:
    `iterator` in interface `Collection<E>`

### 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>`

### isEmpty

    public boolean isEmpty()

  Specified by:
    `isEmpty` 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

### asList

    public ImmutableList<E> asList()

  Returns a list view of the collection.

  Since:
    2.0

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2010-2011. All Rights Reserved.