com.google.common.collect
Class ImmutableCollection<E>
- java.lang.Object
-
- 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
Collectionmethods, 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 and Description static classImmutableCollection.Builder<E>Abstract base class for builders ofImmutableCollectiontypes.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Deprecated Methods Modifier and Type Method and Description booleanadd(E e)Deprecated.Unsupported operation.booleanaddAll(java.util.Collection<? extends E> newElements)Deprecated.Unsupported operation.ImmutableList<E>asList()Returns a list view of the collection.voidclear()Deprecated.Unsupported operation.booleancontains(java.lang.Object object)booleancontainsAll(java.util.Collection<?> targets)booleanisEmpty()abstract UnmodifiableIterator<E>iterator()Returns an unmodifiable iterator across the elements in this collection.booleanremove(java.lang.Object object)Deprecated.Unsupported operation.booleanremoveAll(java.util.Collection<?> oldElements)Deprecated.Unsupported operation.booleanretainAll(java.util.Collection<?> elementsToKeep)Deprecated.Unsupported operation.java.lang.Object[]toArray()<T> T[]toArray(T[] other)java.lang.StringtoString()-
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 java.lang.Object[] toArray()
- Specified by:
toArrayin interfacejava.util.Collection<E>
-
toArray
public <T> T[] toArray(T[] other)
- Specified by:
toArrayin interfacejava.util.Collection<E>
-
contains
public boolean contains(@Nullable java.lang.Object object)- Specified by:
containsin interfacejava.util.Collection<E>
-
containsAll
public boolean containsAll(java.util.Collection<?> targets)
- Specified by:
containsAllin interfacejava.util.Collection<E>
-
isEmpty
public boolean isEmpty()
- Specified by:
isEmptyin interfacejava.util.Collection<E>
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.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:
addin interfacejava.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:
removein interfacejava.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:
addAllin interfacejava.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:
removeAllin interfacejava.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:
retainAllin interfacejava.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:
clearin interfacejava.util.Collection<E>- Throws:
java.lang.UnsupportedOperationException- always
-
asList
public ImmutableList<E> asList()
Returns a list view of the collection.- Since:
- 2.0
-
-
DMelt 3.0 © DataMelt by jWork.ORG