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:35 UTC

svn commit: r815062 - /commons/proper/collections/trunk/src/java/org/apache/commons/collections/list/AbstractListDecorator.java

Author: bayard
Date: Tue Sep 15 05:55:35 2009
New Revision: 815062

URL: http://svn.apache.org/viewvc?rev=815062&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()
    ------------------------------------------------------------------------
    r471173 | scolebourne | 2006-11-04 04:07:39 -0800 (Sat, 04 Nov 2006) | 1 line
    
    Abstract*Decorator - Generify and use covariant return types
    ------------------------------------------------------------------------

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

Modified: commons/proper/collections/trunk/src/java/org/apache/commons/collections/list/AbstractListDecorator.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/java/org/apache/commons/collections/list/AbstractListDecorator.java?rev=815062&r1=815061&r2=815062&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/java/org/apache/commons/collections/list/AbstractListDecorator.java (original)
+++ commons/proper/collections/trunk/src/java/org/apache/commons/collections/list/AbstractListDecorator.java Tue Sep 15 05:55:35 2009
@@ -27,12 +27,17 @@
  * <p>
  * Methods are forwarded directly to the decorated list.
  *
+ * @param <E> the type of the elements in the list
  * @since Commons Collections 3.0
  * @version $Revision$ $Date$
  *
  * @author Stephen Colebourne
  */
-public abstract class AbstractListDecorator extends AbstractCollectionDecorator implements List {
+public abstract class AbstractListDecorator<E> extends AbstractCollectionDecorator<E> implements
+        List<E> {
+
+    /** Serialization version--necessary in an abstract class? */
+    private static final long serialVersionUID = 4500739654952315623L;
 
     /**
      * Constructor only used in deserialization, do not use otherwise.
@@ -48,7 +53,7 @@
      * @param list  the list to decorate, must not be null
      * @throws IllegalArgumentException if list is null
      */
-    protected AbstractListDecorator(List list) {
+    protected AbstractListDecorator(List<E> list) {
         super(list);
     }
 
@@ -57,49 +62,49 @@
      * 
      * @return the decorated list
      */
-    protected List getList() {
-        return (List) getCollection();
+    protected List<E> decorated() {
+        return (List<E>) super.decorated();
     }
 
     //-----------------------------------------------------------------------
-    public void add(int index, Object object) {
-        getList().add(index, object);
+    public void add(int index, E object) {
+        decorated().add(index, object);
     }
 
-    public boolean addAll(int index, Collection coll) {
-        return getList().addAll(index, coll);
+    public boolean addAll(int index, Collection<? extends E> coll) {
+        return decorated().addAll(index, coll);
     }
 
-    public Object get(int index) {
-        return getList().get(index);
+    public E get(int index) {
+        return decorated().get(index);
     }
 
     public int indexOf(Object object) {
-        return getList().indexOf(object);
+        return decorated().indexOf(object);
     }
 
     public int lastIndexOf(Object object) {
-        return getList().lastIndexOf(object);
+        return decorated().lastIndexOf(object);
     }
 
-    public ListIterator listIterator() {
-        return getList().listIterator();
+    public ListIterator<E> listIterator() {
+        return decorated().listIterator();
     }
 
-    public ListIterator listIterator(int index) {
-        return getList().listIterator(index);
+    public ListIterator<E> listIterator(int index) {
+        return decorated().listIterator(index);
     }
 
-    public Object remove(int index) {
-        return getList().remove(index);
+    public E remove(int index) {
+        return decorated().remove(index);
     }
 
-    public Object set(int index, Object object) {
-        return getList().set(index, object);
+    public E set(int index, E object) {
+        return decorated().set(index, object);
     }
 
-    public List subList(int fromIndex, int toIndex) {
-        return getList().subList(fromIndex, toIndex);
+    public List<E> subList(int fromIndex, int toIndex) {
+        return decorated().subList(fromIndex, toIndex);
     }
 
 }