commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bay...@apache.org
Subject svn commit: r815068 - /commons/proper/collections/trunk/src/java/org/apache/commons/collections/list/UnmodifiableList.java
Date Tue, 15 Sep 2009 05:55:47 GMT
Author: bayard
Date: Tue Sep 15 05:55:47 2009
New Revision: 815068

URL: http://svn.apache.org/viewvc?rev=815068&view=rev
Log:
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()
    ------------------------------------------------------------------------

Modified:
    commons/proper/collections/trunk/src/java/org/apache/commons/collections/list/UnmodifiableList.java

Modified: commons/proper/collections/trunk/src/java/org/apache/commons/collections/list/UnmodifiableList.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/java/org/apache/commons/collections/list/UnmodifiableList.java?rev=815068&r1=815067&r2=815068&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/java/org/apache/commons/collections/list/UnmodifiableList.java
(original)
+++ commons/proper/collections/trunk/src/java/org/apache/commons/collections/list/UnmodifiableList.java
Tue Sep 15 05:55:47 2009
@@ -37,8 +37,8 @@
  *
  * @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 @@
      * @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 @@
      * 
      * @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 @@
         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);
     }
 
 }



Mime
View raw message