sbrt.kernel.util
Class UnmodifiableCollection<E>

java.lang.Object
  extended by sbrt.kernel.util.UnmodifiableCollection<E>
Type Parameters:
E - the element type.
All Implemented Interfaces:
java.lang.Iterable<E>, java.util.Collection<E>

public class UnmodifiableCollection<E>
extends java.lang.Object
implements java.util.Collection<E>

This class is used to create an unmodifiable view of collections. It is intended to mimic the behavior of java.util.Collections.unmodifiableCollection(java.util.Collection), but in a more explicit way. If a method returns an UnmodifiableCollection, it's clear that the collection is unmodifiable and that UnsupportedOperationException will be thrown if modification is attempted.

Author:
This class was written and documented by Jeremiah Wright while in the Wagner lab.

Constructor Summary
UnmodifiableCollection(java.util.Collection<E> c)
          Constructs a new unmodifiable view of the provided collection.
 
Method Summary
 boolean add(E o)
          See Collection.add(Object).
 boolean addAll(java.util.Collection<? extends E> c)
          See Collection.addAll(Collection).
 void clear()
          See Collection.clear().
 boolean contains(java.lang.Object o)
          See Collection.contains(Object).
 boolean containsAll(java.util.Collection<?> c)
          See Collection.containsAll(Collection).
 boolean equals(java.lang.Object obj)
          See Collection.equals(Object).
 int hashCode()
          See Collection.hashCode().
 boolean isEmpty()
          See Collection.isEmpty().
 java.util.Iterator<E> iterator()
          See Collection.iterator().
 boolean remove(java.lang.Object o)
          See Collection.remove(Object).
 boolean removeAll(java.util.Collection<?> c)
          See Collection.removeAll(Collection).
 boolean retainAll(java.util.Collection<?> c)
          See Collection.retainAll(Collection).
 int size()
          See Collection.size().
 java.lang.Object[] toArray()
          See Collection.toArray().
<T> T[]
toArray(T[] a)
          See Collection.toArray(Object[]).
 java.lang.String toString()
          Returns toString() on the underlying collection.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

UnmodifiableCollection

public UnmodifiableCollection(java.util.Collection<E> c)
Constructs a new unmodifiable view of the provided collection.

Parameters:
c - the collection for which an unmodifiable view is created.
Method Detail

add

public boolean add(E o)
See Collection.add(Object).

Specified by:
add in interface java.util.Collection<E>

addAll

public boolean addAll(java.util.Collection<? extends E> c)
See Collection.addAll(Collection).

Specified by:
addAll in interface java.util.Collection<E>

clear

public void clear()
See Collection.clear().

Specified by:
clear in interface java.util.Collection<E>

contains

public boolean contains(java.lang.Object o)
See Collection.contains(Object).

Specified by:
contains in interface java.util.Collection<E>

containsAll

public boolean containsAll(java.util.Collection<?> c)
See Collection.containsAll(Collection).

Specified by:
containsAll in interface java.util.Collection<E>

isEmpty

public boolean isEmpty()
See Collection.isEmpty().

Specified by:
isEmpty in interface java.util.Collection<E>

iterator

public java.util.Iterator<E> iterator()
See Collection.iterator().

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

remove

public boolean remove(java.lang.Object o)
See Collection.remove(Object).

Specified by:
remove in interface java.util.Collection<E>

removeAll

public boolean removeAll(java.util.Collection<?> c)
See Collection.removeAll(Collection).

Specified by:
removeAll in interface java.util.Collection<E>

retainAll

public boolean retainAll(java.util.Collection<?> c)
See Collection.retainAll(Collection).

Specified by:
retainAll in interface java.util.Collection<E>

size

public int size()
See Collection.size().

Specified by:
size in interface java.util.Collection<E>

toArray

public java.lang.Object[] toArray()
See Collection.toArray().

Specified by:
toArray in interface java.util.Collection<E>

toArray

public <T> T[] toArray(T[] a)
See Collection.toArray(Object[]).

Specified by:
toArray in interface java.util.Collection<E>

toString

public java.lang.String toString()
Returns toString() on the underlying collection.

Overrides:
toString in class java.lang.Object
Returns:
toString() on the underlying collection.

equals

public boolean equals(java.lang.Object obj)
See Collection.equals(Object).

Specified by:
equals in interface java.util.Collection<E>
Overrides:
equals in class java.lang.Object

hashCode

public int hashCode()
See Collection.hashCode().

Specified by:
hashCode in interface java.util.Collection<E>
Overrides:
hashCode in class java.lang.Object