Merging from -r468106:814127 of collections_jdk5_branch - namely where this code was generified; mostly in r738956.

Also see the following revisions:

    ------------------------------------------------------------------------
    r471202 | scolebourne | 2006-11-04 06:21:44 -0800 (Sat, 04 Nov 2006) | 1 line
    
    Remove getCollection() - use covariant decorated()
    ------------------------------------------------------------------------
    r471192 | scolebourne | 2006-11-04 06:04:46 -0800 (Sat, 04 Nov 2006) | 1 line
    
    Remove getList() - use decorated()
    ------------------------------------------------------------------------


git-svn-id: https://svn.apache.org/repos/asf/commons/proper/collections/trunk@815068 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Henri Yandell 2009-09-15 05:55:47 +00:00
parent 1dbcde91cb
commit 9c4574b68d
1 changed files with 22 additions and 21 deletions

View File

@ -37,8 +37,8 @@ import org.apache.commons.collections.iterators.UnmodifiableListIterator;
*
* @author Stephen Colebourne
*/
public final class UnmodifiableList
extends AbstractSerializableListDecorator
public final class UnmodifiableList<E>
extends AbstractSerializableListDecorator<E>
implements Unmodifiable {
/** Serialization version */
@ -50,11 +50,11 @@ public final class UnmodifiableList
* @param list the list to decorate, must not be null
* @throws IllegalArgumentException if list is null
*/
public static List decorate(List list) {
public static <E> List<E> decorate(List<E> list) {
if (list instanceof Unmodifiable) {
return list;
}
return new UnmodifiableList(list);
return new UnmodifiableList<E>(list);
}
//-----------------------------------------------------------------------
@ -63,21 +63,22 @@ public final class UnmodifiableList
*
* @param list the list to decorate, must not be null
* @throws IllegalArgumentException if list is null
* @since Commons Collection 5
*/
private UnmodifiableList(List list) {
public UnmodifiableList(List<E> list) {
super(list);
}
//-----------------------------------------------------------------------
public Iterator iterator() {
return UnmodifiableIterator.decorate(getCollection().iterator());
public Iterator<E> iterator() {
return UnmodifiableIterator.decorate(decorated().iterator());
}
public boolean add(Object object) {
throw new UnsupportedOperationException();
}
public boolean addAll(Collection coll) {
public boolean addAll(Collection<? extends E> coll) {
throw new UnsupportedOperationException();
}
@ -89,42 +90,42 @@ public final class UnmodifiableList
throw new UnsupportedOperationException();
}
public boolean removeAll(Collection coll) {
public boolean removeAll(Collection<?> coll) {
throw new UnsupportedOperationException();
}
public boolean retainAll(Collection coll) {
public boolean retainAll(Collection<?> coll) {
throw new UnsupportedOperationException();
}
//-----------------------------------------------------------------------
public ListIterator listIterator() {
return UnmodifiableListIterator.decorate(getList().listIterator());
public ListIterator<E> listIterator() {
return UnmodifiableListIterator.decorate(decorated().listIterator());
}
public ListIterator listIterator(int index) {
return UnmodifiableListIterator.decorate(getList().listIterator(index));
public ListIterator<E> listIterator(int index) {
return UnmodifiableListIterator.decorate(decorated().listIterator(index));
}
public void add(int index, Object object) {
public void add(int index, E object) {
throw new UnsupportedOperationException();
}
public boolean addAll(int index, Collection coll) {
public boolean addAll(int index, Collection<? extends E> coll) {
throw new UnsupportedOperationException();
}
public Object remove(int index) {
public E remove(int index) {
throw new UnsupportedOperationException();
}
public Object set(int index, Object object) {
public E set(int index, E object) {
throw new UnsupportedOperationException();
}
public List subList(int fromIndex, int toIndex) {
List sub = getList().subList(fromIndex, toIndex);
return new UnmodifiableList(sub);
public List<E> subList(int fromIndex, int toIndex) {
List<E> sub = decorated().subList(fromIndex, toIndex);
return new UnmodifiableList<E>(sub);
}
}