You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by ba...@apache.org on 2009/09/15 07:55:39 UTC

svn commit: r815064 - /commons/proper/collections/trunk/src/java/org/apache/commons/collections/list/GrowthList.java

Author: bayard
Date: Tue Sep 15 05:55:39 2009
New Revision: 815064

URL: http://svn.apache.org/viewvc?rev=815064&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:

    ------------------------------------------------------------------------
    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/GrowthList.java

Modified: commons/proper/collections/trunk/src/java/org/apache/commons/collections/list/GrowthList.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/java/org/apache/commons/collections/list/GrowthList.java?rev=815064&r1=815063&r2=815064&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/java/org/apache/commons/collections/list/GrowthList.java (original)
+++ commons/proper/collections/trunk/src/java/org/apache/commons/collections/list/GrowthList.java Tue Sep 15 05:55:39 2009
@@ -55,7 +55,7 @@
  * @author Stephen Colebourne
  * @author Paul Legato
  */
-public class GrowthList extends AbstractSerializableListDecorator {
+public class GrowthList<E> extends AbstractSerializableListDecorator<E> {
 
     /** Serialization version */
     private static final long serialVersionUID = -3620001881672L;
@@ -66,8 +66,8 @@
      * @param list  the list to decorate, must not be null
      * @throws IllegalArgumentException if list is null
      */
-    public static List decorate(List list) {
-        return new GrowthList(list);
+    public static <E> List<E> decorate(List<E> list) {
+        return new GrowthList<E>(list);
     }
 
     //-----------------------------------------------------------------------
@@ -75,7 +75,7 @@
      * Constructor that uses an ArrayList internally.
      */
     public GrowthList() {
-        super(new ArrayList());
+        super(new ArrayList<E>());
     }
 
     /**
@@ -85,7 +85,7 @@
      * @throws IllegalArgumentException if initial size is invalid
      */
     public GrowthList(int initialSize) {
-        super(new ArrayList(initialSize));
+        super(new ArrayList<E>(initialSize));
     }
 
     /**
@@ -94,7 +94,7 @@
      * @param list  the list to decorate, must not be null
      * @throws IllegalArgumentException if list is null
      */
-    protected GrowthList(List list) {
+    protected GrowthList(List<E> list) {
         super(list);
     }
 
@@ -117,12 +117,12 @@
      * @throws ClassCastException if the underlying list rejects the element
      * @throws IllegalArgumentException if the underlying list rejects the element
      */
-    public void add(int index, Object element) {
-        int size = getList().size();
+    public void add(int index, E element) {
+        int size = decorated().size();
         if (index > size) {
-            getList().addAll(Collections.nCopies(index - size, null));
+            decorated().addAll(Collections.<E>nCopies(index - size, null));
         }
-        getList().add(index, element);
+        decorated().add(index, element);
     }
 
     //-----------------------------------------------------------------------
@@ -145,14 +145,14 @@
      * @throws ClassCastException if the underlying list rejects the element
      * @throws IllegalArgumentException if the underlying list rejects the element
      */
-    public boolean addAll(int index, Collection coll) {
-        int size = getList().size();
+    public boolean addAll(int index, Collection<? extends E> coll) {
+        int size = decorated().size();
         boolean result = false;
         if (index > size) {
-            getList().addAll(Collections.nCopies(index - size, null));
+            decorated().addAll(Collections.<E>nCopies(index - size, null));
             result = true;
         }
-        return (getList().addAll(index, coll) | result);
+        return (decorated().addAll(index, coll) | result);
     }
 
     //-----------------------------------------------------------------------
@@ -175,12 +175,12 @@
      * @throws ClassCastException if the underlying list rejects the element
      * @throws IllegalArgumentException if the underlying list rejects the element
      */
-    public Object set(int index, Object element) {
-        int size = getList().size();
+    public E set(int index, E element) {
+        int size = decorated().size();
         if (index >= size) {
-            getList().addAll(Collections.nCopies((index - size) + 1, null));
+            decorated().addAll(Collections.<E>nCopies((index - size) + 1, null));
         }
-        return getList().set(index, element);
+        return decorated().set(index, element);
     }
 
 }