Author: bayard
Date: Tue Sep 15 05:54:53 2009
New Revision: 815041

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

    ------------------------------------------------------------------------
    r471575 | scolebourne | 2006-11-05 15:58:08 -0800 (Sun, 05 Nov 2006) | 1 
line
    
    Generify and remove AbstractSerializableCollectionDecorator
    ------------------------------------------------------------------------
    r471202 | scolebourne | 2006-11-04 06:21:44 -0800 (Sat, 04 Nov 2006) | 1 
line
    
    Remove getCollection() - use covariant decorated()
    ------------------------------------------------------------------------

Modified:
    
commons/proper/collections/trunk/src/java/org/apache/commons/collections/collection/UnmodifiableCollection.java

Modified: 
commons/proper/collections/trunk/src/java/org/apache/commons/collections/collection/UnmodifiableCollection.java
URL: 
http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/java/org/apache/commons/collections/collection/UnmodifiableCollection.java?rev=815041&r1=815040&r2=815041&view=diff
==============================================================================
--- 
commons/proper/collections/trunk/src/java/org/apache/commons/collections/collection/UnmodifiableCollection.java
 (original)
+++ 
commons/proper/collections/trunk/src/java/org/apache/commons/collections/collection/UnmodifiableCollection.java
 Tue Sep 15 05:54:53 2009
@@ -29,13 +29,14 @@
  * <p>
  * Attempts to modify it will result in an UnsupportedOperationException. 
  *
+ * @param <E> the type of the elements in the collection
  * @since Commons Collections 3.0
  * @version $Revision$ $Date$
  *
  * @author Stephen Colebourne
  */
-public final class UnmodifiableCollection
-        extends AbstractSerializableCollectionDecorator
+public final class UnmodifiableCollection<E>
+        extends AbstractCollectionDecorator<E>
         implements Unmodifiable {
 
     /** Serialization version */
@@ -46,17 +47,18 @@
      * <p>
      * If the collection passed in is already unmodifiable, it is returned.
      * 
+     * @param <T> the type of the elements in the collection
      * @param coll  the collection to decorate, must not be null
      * @return an unmodifiable collection
      * @throws IllegalArgumentException if collection is null
      */
-    public static Collection decorate(Collection coll) {
+    public static <T> Collection<T> decorate(Collection<T> coll) {
         if (coll instanceof Unmodifiable) {
             return coll;
         }
-        return new UnmodifiableCollection(coll);
+        return new UnmodifiableCollection<T>(coll);
     }
-    
+
     //-----------------------------------------------------------------------
     /**
      * Constructor that wraps (not copies).
@@ -64,20 +66,20 @@
      * @param coll  the collection to decorate, must not be null
      * @throws IllegalArgumentException if collection is null
      */
-    private UnmodifiableCollection(Collection coll) {
+    private UnmodifiableCollection(Collection<E> coll) {
         super(coll);
     }
 
     //-----------------------------------------------------------------------
-    public Iterator iterator() {
-        return UnmodifiableIterator.decorate(getCollection().iterator());
+    public Iterator<E> iterator() {
+        return UnmodifiableIterator.decorate(decorated().iterator());
     }
 
-    public boolean add(Object object) {
+    public boolean add(E object) {
         throw new UnsupportedOperationException();
     }
 
-    public boolean addAll(Collection coll) {
+    public boolean addAll(Collection<? extends E> coll) {
         throw new UnsupportedOperationException();
     }
 
@@ -89,11 +91,11 @@
         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();
     }
 


Reply via email to