org.elasticsearch.util.collect
Class ImmutableCollection<E>

java.lang.Object
  extended by org.elasticsearch.util.collect.ImmutableCollection<E>
All Implemented Interfaces:
java.io.Serializable, java.lang.Iterable<E>, java.util.Collection<E>
Direct Known Subclasses:
ImmutableList, ImmutableMultiset, ImmutableSet

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.

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.

See Also:
Serialized Form

Method Summary
 boolean add(E e)
          Guaranteed to throw an exception and leave the collection unmodified.
 boolean addAll(java.util.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(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)
          Guaranteed to throw an exception and leave the collection unmodified.
 boolean removeAll(java.util.Collection<?> oldElements)
          Guaranteed to throw an exception and leave the collection unmodified.
 boolean retainAll(java.util.Collection<?> elementsToKeep)
          Guaranteed to throw an exception and leave the collection unmodified.
 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

public final boolean add(E e)
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

public final boolean remove(java.lang.Object object)
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

public final boolean addAll(java.util.Collection<? extends E> newElements)
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

public final boolean removeAll(java.util.Collection<?> oldElements)
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

public final boolean retainAll(java.util.Collection<?> elementsToKeep)
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

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

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