sbrt.kernel.util
Class UnmodifiableList<E>

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

public class UnmodifiableList<E>
extends java.lang.Object
implements java.util.List<E>

This class is used to create an unmodifiable view of lists. It is intended to mimic the behavior of java.util.Collections.unmodifiableList(List), but in a more explicit way. If a method returns an UnmodifiableList, it's clear that the list 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
UnmodifiableList(java.util.List<E> list)
          Constructs a new unmodifiable view of the provided list.
 
Method Summary
 boolean add(E o)
          See List.add(Object).
 void add(int index, E element)
          See List.add(int, Object).
 boolean addAll(java.util.Collection<? extends E> c)
          See List.addAll(Collection).
 boolean addAll(int index, java.util.Collection<? extends E> c)
          See List.addAll(int, Collection).
 void clear()
          See List.clear().
 boolean contains(java.lang.Object o)
          See List.contains(Object).
 boolean containsAll(java.util.Collection<?> c)
          See List.containsAll(Collection).
 boolean equals(java.lang.Object obj)
          See List.equals(Object).
 E get(int index)
          See List.get(int).
 int hashCode()
          See List.hashCode().
 int indexOf(java.lang.Object o)
          See List.indexOf(Object).
 boolean isEmpty()
          See List.isEmpty().
 java.util.Iterator<E> iterator()
          See List.iterator().
 int lastIndexOf(java.lang.Object o)
          See List.lastIndexOf(Object).
 java.util.ListIterator<E> listIterator()
          See List.listIterator().
 java.util.ListIterator<E> listIterator(int index)
          See List.listIterator(int).
 E remove(int index)
          See List.remove(int).
 boolean remove(java.lang.Object o)
          See List.remove(Object).
 boolean removeAll(java.util.Collection<?> c)
          See List.removeAll(Collection).
 boolean retainAll(java.util.Collection<?> c)
          See List.retainAll(Collection).
 E set(int index, E element)
          See List.set(int, Object).
 int size()
          See List.size().
 java.util.List<E> subList(int fromIndex, int toIndex)
          See List.subList(int, int).
 java.lang.Object[] toArray()
          See List.toArray().
<T> T[]
toArray(T[] a)
          See List.toArray(Object[]).
 java.lang.String toString()
          Returns toString() on the underlying list.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

UnmodifiableList

public UnmodifiableList(java.util.List<E> list)
Constructs a new unmodifiable view of the provided list.

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

add

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

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

add

public void add(int index,
                E element)
See List.add(int, Object).

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

addAll

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

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

addAll

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

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

clear

public void clear()
See List.clear().

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

contains

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

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

containsAll

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

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

get

public E get(int index)
See List.get(int).

Specified by:
get in interface java.util.List<E>

indexOf

public int indexOf(java.lang.Object o)
See List.indexOf(Object).

Specified by:
indexOf in interface java.util.List<E>

isEmpty

public boolean isEmpty()
See List.isEmpty().

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

iterator

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

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

lastIndexOf

public int lastIndexOf(java.lang.Object o)
See List.lastIndexOf(Object).

Specified by:
lastIndexOf in interface java.util.List<E>

listIterator

public java.util.ListIterator<E> listIterator()
See List.listIterator().

Specified by:
listIterator in interface java.util.List<E>

listIterator

public java.util.ListIterator<E> listIterator(int index)
See List.listIterator(int).

Specified by:
listIterator in interface java.util.List<E>

remove

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

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

remove

public E remove(int index)
See List.remove(int).

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

removeAll

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

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

retainAll

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

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

set

public E set(int index,
             E element)
See List.set(int, Object).

Specified by:
set in interface java.util.List<E>

size

public int size()
See List.size().

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

subList

public java.util.List<E> subList(int fromIndex,
                                 int toIndex)
See List.subList(int, int).

Specified by:
subList in interface java.util.List<E>

toArray

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

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

toArray

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

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

toString

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

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

equals

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

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

hashCode

public int hashCode()
See List.hashCode().

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