diff --git a/src/java/org/apache/commons/collections/list/UnmodifiableList.java b/src/java/org/apache/commons/collections/list/UnmodifiableList.java index d76fbeee5..060bc1b23 100644 --- a/src/java/org/apache/commons/collections/list/UnmodifiableList.java +++ b/src/java/org/apache/commons/collections/list/UnmodifiableList.java @@ -37,8 +37,8 @@ import org.apache.commons.collections.iterators.UnmodifiableListIterator; * * @author Stephen Colebourne */ -public final class UnmodifiableList - extends AbstractSerializableListDecorator +public final class UnmodifiableList + extends AbstractSerializableListDecorator 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 List decorate(List list) { if (list instanceof Unmodifiable) { return list; } - return new UnmodifiableList(list); + return new UnmodifiableList(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 list) { super(list); } //----------------------------------------------------------------------- - public Iterator iterator() { - return UnmodifiableIterator.decorate(getCollection().iterator()); + public Iterator iterator() { + return UnmodifiableIterator.decorate(decorated().iterator()); } public boolean add(Object object) { throw new UnsupportedOperationException(); } - public boolean addAll(Collection coll) { + public boolean addAll(Collection 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 listIterator() { + return UnmodifiableListIterator.decorate(decorated().listIterator()); } - public ListIterator listIterator(int index) { - return UnmodifiableListIterator.decorate(getList().listIterator(index)); + public ListIterator 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 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 subList(int fromIndex, int toIndex) { + List sub = decorated().subList(fromIndex, toIndex); + return new UnmodifiableList(sub); } }