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:54:01 UTC

svn commit: r815013 - /commons/proper/collections/trunk/src/java/org/apache/commons/collections/bag/PredicatedBag.java

Author: bayard
Date: Tue Sep 15 05:54:01 2009
New Revision: 815013

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

    ------------------------------------------------------------------------
    r555925 | skestle | 2007-07-13 03:39:24 -0700 (Fri, 13 Jul 2007) | 2 lines
    
    Added Edwin Tellman's patch for COLLECTIONS-243.  
    It all seems pretty reasonable, and it should all be checked again as the project is worked through
    ------------------------------------------------------------------------
    r471201 | scolebourne | 2006-11-04 06:17:26 -0800 (Sat, 04 Nov 2006) | 1 line
    
    Remove getBag() - use covariant decorated()
    ------------------------------------------------------------------------

Modified:
    commons/proper/collections/trunk/src/java/org/apache/commons/collections/bag/PredicatedBag.java

Modified: commons/proper/collections/trunk/src/java/org/apache/commons/collections/bag/PredicatedBag.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/java/org/apache/commons/collections/bag/PredicatedBag.java?rev=815013&r1=815012&r2=815013&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/java/org/apache/commons/collections/bag/PredicatedBag.java (original)
+++ commons/proper/collections/trunk/src/java/org/apache/commons/collections/bag/PredicatedBag.java Tue Sep 15 05:54:01 2009
@@ -41,8 +41,8 @@
  * @author Stephen Colebourne
  * @author Paul Jack
  */
-public class PredicatedBag
-        extends PredicatedCollection implements Bag {
+public class PredicatedBag<E>
+        extends PredicatedCollection<E> implements Bag<E> {
 
     /** Serialization version */
     private static final long serialVersionUID = -2575833140344736876L;
@@ -59,8 +59,8 @@
      * @throws IllegalArgumentException if bag or predicate is null
      * @throws IllegalArgumentException if the bag contains invalid elements
      */
-    public static Bag decorate(Bag bag, Predicate predicate) {
-        return new PredicatedBag(bag, predicate);
+    public static <T> Bag<T> decorate(Bag<T> bag, Predicate<? super T> predicate) {
+        return new PredicatedBag<T>(bag, predicate);
     }
 
     //-----------------------------------------------------------------------
@@ -75,7 +75,7 @@
      * @throws IllegalArgumentException if bag or predicate is null
      * @throws IllegalArgumentException if the bag contains invalid elements
      */
-    protected PredicatedBag(Bag bag, Predicate predicate) {
+    protected PredicatedBag(Bag<E> bag, Predicate<? super E> predicate) {
         super(bag, predicate);
     }
 
@@ -84,26 +84,26 @@
      * 
      * @return the decorated bag
      */
-    protected Bag getBag() {
-        return (Bag) getCollection();
+    protected Bag<E> decorated() {
+        return (Bag<E>) super.decorated();
     }
     
     //-----------------------------------------------------------------------
-    public boolean add(Object object, int count) {
+    public boolean add(E object, int count) {
         validate(object);
-        return getBag().add(object, count);
+        return decorated().add(object, count);
     }
 
     public boolean remove(Object object, int count) {
-        return getBag().remove(object, count);
+        return decorated().remove(object, count);
     }
 
-    public Set uniqueSet() {
-        return getBag().uniqueSet();
+    public Set<E> uniqueSet() {
+        return decorated().uniqueSet();
     }
 
     public int getCount(Object object) {
-        return getBag().getCount(object);
+        return decorated().getCount(object);
     }
 
 }