Return-Path: Delivered-To: apmail-jakarta-commons-dev-archive@www.apache.org Received: (qmail 7902 invoked from network); 13 Jul 2007 23:30:01 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 13 Jul 2007 23:30:01 -0000 Received: (qmail 87538 invoked by uid 500); 13 Jul 2007 23:30:02 -0000 Delivered-To: apmail-jakarta-commons-dev-archive@jakarta.apache.org Received: (qmail 87175 invoked by uid 500); 13 Jul 2007 23:30:00 -0000 Mailing-List: contact commons-dev-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Help: List-Post: List-Id: "Jakarta Commons Developers List" Reply-To: "Jakarta Commons Developers List" Delivered-To: mailing list commons-dev@jakarta.apache.org Received: (qmail 9824 invoked by uid 500); 13 Jul 2007 10:39:54 -0000 X-ASF-Spam-Status: No, hits=-99.5 required=10.0 tests=ALL_TRUSTED,NO_REAL_NAME X-Spam-Check-By: apache.org Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r555925 - in /jakarta/commons/proper/collections/branches/collections_jdk5_branch/src: java/org/apache/commons/collections/ java/org/apache/commons/collections/bag/ java/org/apache/commons/collections/buffer/ java/org/apache/commons/collect... Date: Fri, 13 Jul 2007 10:39:28 -0000 To: commons-cvs@jakarta.apache.org From: skestle@apache.org X-Mailer: svnmailer-1.1.0 Message-Id: <20070713103929.6C5001A981A@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: skestle Date: Fri Jul 13 03:39:24 2007 New Revision: 555925 URL: http://svn.apache.org/viewvc?view=rev&rev=555925 Log: 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 Modified: jakarta/commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/Bag.java jakarta/commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/BagUtils.java jakarta/commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/ListUtils.java jakarta/commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/SetUtils.java jakarta/commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/bag/AbstractBagDecorator.java jakarta/commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/bag/AbstractSortedBagDecorator.java jakarta/commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/bag/PredicatedBag.java jakarta/commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/bag/PredicatedSortedBag.java jakarta/commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/bag/SynchronizedBag.java jakarta/commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/bag/SynchronizedSortedBag.java jakarta/commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/bag/UnmodifiableSortedBag.java jakarta/commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/buffer/PredicatedBuffer.java jakarta/commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/collection/AbstractCollectionDecorator.java jakarta/commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/collection/TransformedCollection.java jakarta/commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/iterators/AbstractListIteratorDecorator.java jakarta/commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/list/PredicatedList.java jakarta/commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/list/SynchronizedList.java jakarta/commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/set/PredicatedSet.java jakarta/commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/set/PredicatedSortedSet.java jakarta/commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/set/SynchronizedSet.java jakarta/commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/set/SynchronizedSortedSet.java jakarta/commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/set/UnmodifiableSortedSet.java jakarta/commons/proper/collections/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/TestListUtils.java Modified: jakarta/commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/Bag.java URL: http://svn.apache.org/viewvc/jakarta/commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/Bag.java?view=diff&rev=555925&r1=555924&r2=555925 ============================================================================== --- jakarta/commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/Bag.java (original) +++ jakarta/commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/Bag.java Fri Jul 13 03:39:24 2007 @@ -55,7 +55,7 @@ * @param object the object to search for * @return the number of occurrences of the object, zero if not found */ - int getCount(E object); + int getCount(Object object); /** * (Violation) @@ -112,7 +112,7 @@ * @param nCopies the number of copies to remove * @return true if this call changed the collection */ - boolean remove(E object, int nCopies); + boolean remove(Object object, int nCopies); /** * Returns a {@link Set} of unique elements in the Bag. Modified: jakarta/commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/BagUtils.java URL: http://svn.apache.org/viewvc/jakarta/commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/BagUtils.java?view=diff&rev=555925&r1=555924&r2=555925 ============================================================================== --- jakarta/commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/BagUtils.java (original) +++ jakarta/commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/BagUtils.java Fri Jul 13 03:39:24 2007 @@ -85,7 +85,7 @@ * @return a synchronized bag backed by that bag * @throws IllegalArgumentException if the Bag is null */ - public static Bag synchronizedBag(Bag bag) { + public static Bag synchronizedBag(Bag bag) { return SynchronizedBag.decorate(bag); } @@ -98,7 +98,7 @@ * @return an unmodifiable view of that bag * @throws IllegalArgumentException if the Bag is null */ - public static Bag unmodifiableBag(Bag bag) { + public static Bag unmodifiableBag(Bag bag) { return UnmodifiableBag.decorate(bag); } @@ -115,7 +115,7 @@ * @return a predicated bag backed by the given bag * @throws IllegalArgumentException if the Bag or Predicate is null */ - public static Bag predicatedBag(Bag bag, Predicate predicate) { + public static Bag predicatedBag(Bag bag, Predicate predicate) { return PredicatedBag.decorate(bag, predicate); } @@ -163,7 +163,7 @@ * @return a synchronized bag backed by that bag * @throws IllegalArgumentException if the SortedBag is null */ - public static SortedBag synchronizedSortedBag(SortedBag bag) { + public static SortedBag synchronizedSortedBag(SortedBag bag) { return SynchronizedSortedBag.decorate(bag); } @@ -176,7 +176,7 @@ * @return an unmodifiable view of that bag * @throws IllegalArgumentException if the SortedBag is null */ - public static SortedBag unmodifiableSortedBag(SortedBag bag) { + public static SortedBag unmodifiableSortedBag(SortedBag bag) { return UnmodifiableSortedBag.decorate(bag); } @@ -193,7 +193,7 @@ * @return a predicated bag backed by the given bag * @throws IllegalArgumentException if the SortedBag or Predicate is null */ - public static SortedBag predicatedSortedBag(SortedBag bag, Predicate predicate) { + public static SortedBag predicatedSortedBag(SortedBag bag, Predicate predicate) { return PredicatedSortedBag.decorate(bag, predicate); } Modified: jakarta/commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/ListUtils.java URL: http://svn.apache.org/viewvc/jakarta/commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/ListUtils.java?view=diff&rev=555925&r1=555924&r2=555925 ============================================================================== --- jakarta/commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/ListUtils.java (original) +++ jakarta/commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/ListUtils.java Fri Jul 13 03:39:24 2007 @@ -68,7 +68,7 @@ * @throws NullPointerException if either list is null */ public static List intersection(final List list1, final List list2) { - final ArrayList result = new ArrayList(); + final List result = new ArrayList(); final Iterator iterator = list2.iterator(); while (iterator.hasNext()) { @@ -203,16 +203,15 @@ * @param list the list to generate the hashCode for, may be null * @return the hash code */ - public static int hashCodeForList(final Collection list) { + public static int hashCodeForList(final Collection list) { if (list == null) { return 0; } int hashCode = 1; - Iterator it = list.iterator(); - Object obj = null; + Iterator it = list.iterator(); while (it.hasNext()) { - obj = it.next(); + E obj = it.next(); hashCode = 31 * hashCode + (obj == null ? 0 : obj.hashCode()); } return hashCode; @@ -234,11 +233,10 @@ * @throws NullPointerException if either parameter is null * @since Commons Collections 3.2 */ - public static List retainAll(Collection collection, Collection retain) { - List list = new ArrayList(Math.min(collection.size(), retain.size())); + public static List retainAll(Collection collection, Collection retain) { + List list = new ArrayList(Math.min(collection.size(), retain.size())); - for (Iterator iter = collection.iterator(); iter.hasNext();) { - Object obj = iter.next(); + for (E obj : collection) { if (retain.contains(obj)) { list.add(obj); } @@ -262,11 +260,10 @@ * @throws NullPointerException if either parameter is null * @since Commons Collections 3.2 */ - public static List removeAll(Collection collection, Collection remove) { - List list = new ArrayList(); - for (Iterator iter = collection.iterator(); iter.hasNext();) { - Object obj = iter.next(); - if (remove.contains(obj) == false) { + public static List removeAll(Collection collection, Collection remove) { + List list = new ArrayList(); + for (E obj : collection) { + if (!remove.contains(obj)) { list.add(obj); } } @@ -296,7 +293,7 @@ * @return a synchronized list backed by the given list * @throws IllegalArgumentException if the list is null */ - public static List synchronizedList(List list) { + public static List synchronizedList(List list) { return SynchronizedList.decorate(list); } @@ -309,7 +306,7 @@ * @return an unmodifiable list backed by the given list * @throws IllegalArgumentException if the list is null */ - public static List unmodifiableList(List list) { + public static List unmodifiableList(List list) { return UnmodifiableList.decorate(list); } @@ -326,7 +323,7 @@ * @return a predicated list backed by the given list * @throws IllegalArgumentException if the List or Predicate is null */ - public static List predicatedList(List list, Predicate predicate) { + public static List predicatedList(List list, Predicate predicate) { return PredicatedList.decorate(list, predicate); } Modified: jakarta/commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/SetUtils.java URL: http://svn.apache.org/viewvc/jakarta/commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/SetUtils.java?view=diff&rev=555925&r1=555924&r2=555925 ============================================================================== --- jakarta/commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/SetUtils.java (original) +++ jakarta/commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/SetUtils.java Fri Jul 13 03:39:24 2007 @@ -117,16 +117,13 @@ * @param set the set to calculate the hash code for, may be null * @return the hash code */ - public static int hashCodeForSet(final Collection set) { + public static int hashCodeForSet(final Collection set) { if (set == null) { return 0; } - int hashCode = 0; - Iterator it = set.iterator(); - Object obj = null; - while (it.hasNext()) { - obj = it.next(); + int hashCode = 0; + for (T obj : set) { if (obj != null) { hashCode += obj.hashCode(); } @@ -157,7 +154,7 @@ * @return a synchronized set backed by the given set * @throws IllegalArgumentException if the set is null */ - public static Set synchronizedSet(Set set) { + public static Set synchronizedSet(Set set) { return SynchronizedSet.decorate(set); } @@ -187,7 +184,7 @@ * @return a predicated set backed by the given set * @throws IllegalArgumentException if the Set or Predicate is null */ - public static Set predicatedSet(Set set, Predicate predicate) { + public static Set predicatedSet(Set set, Predicate predicate) { return PredicatedSet.decorate(set, predicate); } @@ -245,7 +242,7 @@ * @return a synchronized set backed by the given set * @throws IllegalArgumentException if the set is null */ - public static SortedSet synchronizedSortedSet(SortedSet set) { + public static SortedSet synchronizedSortedSet(SortedSet set) { return SynchronizedSortedSet.decorate(set); } @@ -258,7 +255,7 @@ * @return an unmodifiable set backed by the given set * @throws IllegalArgumentException if the set is null */ - public static SortedSet unmodifiableSortedSet(SortedSet set) { + public static SortedSet unmodifiableSortedSet(SortedSet set) { return UnmodifiableSortedSet.decorate(set); } @@ -275,7 +272,7 @@ * @return a predicated sorted set backed by the given sorted set * @throws IllegalArgumentException if the Set or Predicate is null */ - public static SortedSet predicatedSortedSet(SortedSet set, Predicate predicate) { + public static SortedSet predicatedSortedSet(SortedSet set, Predicate predicate) { return PredicatedSortedSet.decorate(set, predicate); } Modified: jakarta/commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/bag/AbstractBagDecorator.java URL: http://svn.apache.org/viewvc/jakarta/commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/bag/AbstractBagDecorator.java?view=diff&rev=555925&r1=555924&r2=555925 ============================================================================== --- jakarta/commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/bag/AbstractBagDecorator.java (original) +++ jakarta/commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/bag/AbstractBagDecorator.java Fri Jul 13 03:39:24 2007 @@ -31,8 +31,8 @@ * * @author Stephen Colebourne */ -public abstract class AbstractBagDecorator - extends AbstractCollectionDecorator implements Bag { +public abstract class AbstractBagDecorator + extends AbstractCollectionDecorator implements Bag { /** * Constructor only used in deserialization, do not use otherwise. @@ -48,7 +48,7 @@ * @param bag the bag to decorate, must not be null * @throws IllegalArgumentException if list is null */ - protected AbstractBagDecorator(Bag bag) { + protected AbstractBagDecorator(Bag bag) { super(bag); } @@ -57,8 +57,8 @@ * * @return the decorated bag */ - protected Bag decorated() { - return (Bag) super.decorated(); + protected Bag decorated() { + return (Bag) super.decorated(); } //----------------------------------------------------------------------- @@ -66,7 +66,7 @@ return decorated().getCount(object); } - public boolean add(Object object, int count) { + public boolean add(E object, int count) { return decorated().add(object, count); } @@ -74,7 +74,7 @@ return decorated().remove(object, count); } - public Set uniqueSet() { + public Set uniqueSet() { return decorated().uniqueSet(); } Modified: jakarta/commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/bag/AbstractSortedBagDecorator.java URL: http://svn.apache.org/viewvc/jakarta/commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/bag/AbstractSortedBagDecorator.java?view=diff&rev=555925&r1=555924&r2=555925 ============================================================================== --- jakarta/commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/bag/AbstractSortedBagDecorator.java (original) +++ jakarta/commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/bag/AbstractSortedBagDecorator.java Fri Jul 13 03:39:24 2007 @@ -30,8 +30,8 @@ * * @author Stephen Colebourne */ -public abstract class AbstractSortedBagDecorator - extends AbstractBagDecorator implements SortedBag { +public abstract class AbstractSortedBagDecorator + extends AbstractBagDecorator implements SortedBag { /** * Constructor only used in deserialization, do not use otherwise. @@ -47,7 +47,7 @@ * @param bag the bag to decorate, must not be null * @throws IllegalArgumentException if list is null */ - protected AbstractSortedBagDecorator(SortedBag bag) { + protected AbstractSortedBagDecorator(SortedBag bag) { super(bag); } @@ -56,20 +56,20 @@ * * @return the decorated bag */ - protected SortedBag decorated() { - return (SortedBag) super.decorated(); + protected SortedBag decorated() { + return (SortedBag) super.decorated(); } //----------------------------------------------------------------------- - public Object first() { + public E first() { return decorated().first(); } - public Object last() { + public E last() { return decorated().last(); } - public Comparator comparator() { + public Comparator comparator() { return decorated().comparator(); } Modified: jakarta/commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/bag/PredicatedBag.java URL: http://svn.apache.org/viewvc/jakarta/commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/bag/PredicatedBag.java?view=diff&rev=555925&r1=555924&r2=555925 ============================================================================== --- jakarta/commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/bag/PredicatedBag.java (original) +++ jakarta/commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/bag/PredicatedBag.java Fri Jul 13 03:39:24 2007 @@ -41,8 +41,8 @@ * @author Stephen Colebourne * @author Paul Jack */ -public class PredicatedBag - extends PredicatedCollection implements Bag { +public class PredicatedBag + extends PredicatedCollection implements Bag { /** 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 Bag decorate(Bag bag, Predicate predicate) { + return new PredicatedBag(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 bag, Predicate predicate) { super(bag, predicate); } @@ -84,12 +84,12 @@ * * @return the decorated bag */ - protected Bag decorated() { - return (Bag) super.decorated(); + protected Bag decorated() { + return (Bag) super.decorated(); } //----------------------------------------------------------------------- - public boolean add(Object object, int count) { + public boolean add(E object, int count) { validate(object); return decorated().add(object, count); } @@ -98,7 +98,7 @@ return decorated().remove(object, count); } - public Set uniqueSet() { + public Set uniqueSet() { return decorated().uniqueSet(); } Modified: jakarta/commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/bag/PredicatedSortedBag.java URL: http://svn.apache.org/viewvc/jakarta/commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/bag/PredicatedSortedBag.java?view=diff&rev=555925&r1=555924&r2=555925 ============================================================================== --- jakarta/commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/bag/PredicatedSortedBag.java (original) +++ jakarta/commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/bag/PredicatedSortedBag.java Fri Jul 13 03:39:24 2007 @@ -40,8 +40,8 @@ * @author Stephen Colebourne * @author Paul Jack */ -public class PredicatedSortedBag - extends PredicatedBag implements SortedBag { +public class PredicatedSortedBag + extends PredicatedBag implements SortedBag { /** Serialization version */ private static final long serialVersionUID = 3448581314086406616L; @@ -58,8 +58,8 @@ * @throws IllegalArgumentException if bag or predicate is null * @throws IllegalArgumentException if the bag contains invalid elements */ - public static SortedBag decorate(SortedBag bag, Predicate predicate) { - return new PredicatedSortedBag(bag, predicate); + public static SortedBag decorate(SortedBag bag, Predicate predicate) { + return new PredicatedSortedBag(bag, predicate); } //----------------------------------------------------------------------- @@ -74,7 +74,7 @@ * @throws IllegalArgumentException if bag or predicate is null * @throws IllegalArgumentException if the bag contains invalid elements */ - protected PredicatedSortedBag(SortedBag bag, Predicate predicate) { + protected PredicatedSortedBag(SortedBag bag, Predicate predicate) { super(bag, predicate); } @@ -83,20 +83,20 @@ * * @return the decorated bag */ - protected SortedBag decorated() { - return (SortedBag) super.decorated(); + protected SortedBag decorated() { + return (SortedBag) super.decorated(); } //----------------------------------------------------------------------- - public Object first() { + public E first() { return decorated().first(); } - public Object last() { + public E last() { return decorated().last(); } - public Comparator comparator() { + public Comparator comparator() { return decorated().comparator(); } Modified: jakarta/commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/bag/SynchronizedBag.java URL: http://svn.apache.org/viewvc/jakarta/commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/bag/SynchronizedBag.java?view=diff&rev=555925&r1=555924&r2=555925 ============================================================================== --- jakarta/commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/bag/SynchronizedBag.java (original) +++ jakarta/commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/bag/SynchronizedBag.java Fri Jul 13 03:39:24 2007 @@ -36,8 +36,8 @@ * * @author Stephen Colebourne */ -public class SynchronizedBag - extends SynchronizedCollection implements Bag { +public class SynchronizedBag + extends SynchronizedCollection implements Bag { /** Serialization version */ private static final long serialVersionUID = 8084674570753837109L; @@ -49,8 +49,8 @@ * @return a new synchronized Bag * @throws IllegalArgumentException if bag is null */ - public static Bag decorate(Bag bag) { - return new SynchronizedBag(bag); + public static Bag decorate(Bag bag) { + return new SynchronizedBag(bag); } //----------------------------------------------------------------------- @@ -60,7 +60,7 @@ * @param bag the bag to decorate, must not be null * @throws IllegalArgumentException if bag is null */ - protected SynchronizedBag(Bag bag) { + protected SynchronizedBag(Bag bag) { super(bag); } @@ -71,7 +71,7 @@ * @param lock the lock to use, must not be null * @throws IllegalArgumentException if bag is null */ - protected SynchronizedBag(Bag bag, Object lock) { + protected SynchronizedBag(Bag bag, Object lock) { super(bag, lock); } @@ -80,12 +80,12 @@ * * @return the decorated bag */ - protected Bag getBag() { - return (Bag) collection; + protected Bag getBag() { + return (Bag) collection; } //----------------------------------------------------------------------- - public boolean add(Object object, int count) { + public boolean add(E object, int count) { synchronized (lock) { return getBag().add(object, count); } @@ -97,9 +97,9 @@ } } - public Set uniqueSet() { + public Set uniqueSet() { synchronized (lock) { - Set set = getBag().uniqueSet(); + Set set = getBag().uniqueSet(); return new SynchronizedBagSet(set, lock); } } @@ -114,13 +114,13 @@ /** * Synchronized Set for the Bag class. */ - class SynchronizedBagSet extends SynchronizedSet { + class SynchronizedBagSet extends SynchronizedSet { /** * Constructor. * @param set the set to decorate * @param lock the lock to use, shared with the bag */ - SynchronizedBagSet(Set set, Object lock) { + SynchronizedBagSet(Set set, Object lock) { super(set, lock); } } Modified: jakarta/commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/bag/SynchronizedSortedBag.java URL: http://svn.apache.org/viewvc/jakarta/commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/bag/SynchronizedSortedBag.java?view=diff&rev=555925&r1=555924&r2=555925 ============================================================================== --- jakarta/commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/bag/SynchronizedSortedBag.java (original) +++ jakarta/commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/bag/SynchronizedSortedBag.java Fri Jul 13 03:39:24 2007 @@ -35,8 +35,8 @@ * * @author Stephen Colebourne */ -public class SynchronizedSortedBag - extends SynchronizedBag implements SortedBag { +public class SynchronizedSortedBag + extends SynchronizedBag implements SortedBag { /** Serialization version */ private static final long serialVersionUID = 722374056718497858L; @@ -48,8 +48,8 @@ * @return a new synchronized SortedBag * @throws IllegalArgumentException if bag is null */ - public static SortedBag decorate(SortedBag bag) { - return new SynchronizedSortedBag(bag); + public static SortedBag decorate(SortedBag bag) { + return new SynchronizedSortedBag(bag); } //----------------------------------------------------------------------- @@ -59,7 +59,7 @@ * @param bag the bag to decorate, must not be null * @throws IllegalArgumentException if bag is null */ - protected SynchronizedSortedBag(SortedBag bag) { + protected SynchronizedSortedBag(SortedBag bag) { super(bag); } @@ -70,7 +70,7 @@ * @param lock the lock to use, must not be null * @throws IllegalArgumentException if bag is null */ - protected SynchronizedSortedBag(Bag bag, Object lock) { + protected SynchronizedSortedBag(Bag bag, Object lock) { super(bag, lock); } @@ -79,24 +79,24 @@ * * @return the decorated bag */ - protected SortedBag getSortedBag() { - return (SortedBag) collection; + protected SortedBag getSortedBag() { + return (SortedBag) collection; } //----------------------------------------------------------------------- - public synchronized Object first() { + public synchronized E first() { synchronized (lock) { return getSortedBag().first(); } } - public synchronized Object last() { + public synchronized E last() { synchronized (lock) { return getSortedBag().last(); } } - public synchronized Comparator comparator() { + public synchronized Comparator comparator() { synchronized (lock) { return getSortedBag().comparator(); } Modified: jakarta/commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/bag/UnmodifiableSortedBag.java URL: http://svn.apache.org/viewvc/jakarta/commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/bag/UnmodifiableSortedBag.java?view=diff&rev=555925&r1=555924&r2=555925 ============================================================================== --- jakarta/commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/bag/UnmodifiableSortedBag.java (original) +++ jakarta/commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/bag/UnmodifiableSortedBag.java Fri Jul 13 03:39:24 2007 @@ -39,8 +39,8 @@ * * @author Stephen Colebourne */ -public final class UnmodifiableSortedBag - extends AbstractSortedBagDecorator implements Unmodifiable, Serializable { +public final class UnmodifiableSortedBag + extends AbstractSortedBagDecorator implements Unmodifiable, Serializable { /** Serialization version */ private static final long serialVersionUID = -3190437252665717841L; @@ -54,11 +54,11 @@ * @return an unmodifiable SortedBag * @throws IllegalArgumentException if bag is null */ - public static SortedBag decorate(SortedBag bag) { + public static SortedBag decorate(SortedBag bag) { if (bag instanceof Unmodifiable) { return bag; } - return new UnmodifiableSortedBag(bag); + return new UnmodifiableSortedBag(bag); } //----------------------------------------------------------------------- @@ -68,7 +68,7 @@ * @param bag the bag to decorate, must not be null * @throws IllegalArgumentException if bag is null */ - private UnmodifiableSortedBag(SortedBag bag) { + private UnmodifiableSortedBag(SortedBag bag) { super(bag); } @@ -93,7 +93,7 @@ */ private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { in.defaultReadObject(); - collection = (Collection) in.readObject(); + collection = (Collection) in.readObject(); } //----------------------------------------------------------------------- @@ -101,11 +101,11 @@ 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 coll) { throw new UnsupportedOperationException(); } @@ -117,16 +117,16 @@ 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 boolean add(Object object, int count) { + public boolean add(E object, int count) { throw new UnsupportedOperationException(); } @@ -134,8 +134,8 @@ throw new UnsupportedOperationException(); } - public Set uniqueSet() { - Set set = decorated().uniqueSet(); + public Set uniqueSet() { + Set set = decorated().uniqueSet(); return UnmodifiableSet.decorate(set); } Modified: jakarta/commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/buffer/PredicatedBuffer.java URL: http://svn.apache.org/viewvc/jakarta/commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/buffer/PredicatedBuffer.java?view=diff&rev=555925&r1=555924&r2=555925 ============================================================================== --- jakarta/commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/buffer/PredicatedBuffer.java (original) +++ jakarta/commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/buffer/PredicatedBuffer.java Fri Jul 13 03:39:24 2007 @@ -39,7 +39,7 @@ * @author Stephen Colebourne * @author Paul Jack */ -public class PredicatedBuffer extends PredicatedCollection implements Buffer { +public class PredicatedBuffer extends PredicatedCollection implements Buffer { /** Serialization version */ private static final long serialVersionUID = 2307609000539943581L; @@ -56,8 +56,8 @@ * @throws IllegalArgumentException if buffer or predicate is null * @throws IllegalArgumentException if the buffer contains invalid elements */ - public static Buffer decorate(Buffer buffer, Predicate predicate) { - return new PredicatedBuffer(buffer, predicate); + public static Buffer decorate(Buffer buffer, Predicate predicate) { + return new PredicatedBuffer(buffer, predicate); } //----------------------------------------------------------------------- @@ -72,7 +72,7 @@ * @throws IllegalArgumentException if buffer or predicate is null * @throws IllegalArgumentException if the buffer contains invalid elements */ - protected PredicatedBuffer(Buffer buffer, Predicate predicate) { + protected PredicatedBuffer(Buffer buffer, Predicate predicate) { super(buffer, predicate); } @@ -81,16 +81,16 @@ * * @return the decorated buffer */ - protected Buffer decorated() { - return (Buffer) super.decorated(); + protected Buffer decorated() { + return (Buffer) super.decorated(); } //----------------------------------------------------------------------- - public Object get() { + public E get() { return decorated().get(); } - public Object remove() { + public E remove() { return decorated().remove(); } Modified: jakarta/commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/collection/AbstractCollectionDecorator.java URL: http://svn.apache.org/viewvc/jakarta/commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/collection/AbstractCollectionDecorator.java?view=diff&rev=555925&r1=555924&r2=555925 ============================================================================== --- jakarta/commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/collection/AbstractCollectionDecorator.java (original) +++ jakarta/commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/collection/AbstractCollectionDecorator.java Fri Jul 13 03:39:24 2007 @@ -136,10 +136,7 @@ } public boolean equals(Object object) { - if (object == this) { - return true; - } - return decorated().equals(object); + return object == this || decorated().equals(object); } public int hashCode() { Modified: jakarta/commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/collection/TransformedCollection.java URL: http://svn.apache.org/viewvc/jakarta/commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/collection/TransformedCollection.java?view=diff&rev=555925&r1=555924&r2=555925 ============================================================================== --- jakarta/commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/collection/TransformedCollection.java (original) +++ jakarta/commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/collection/TransformedCollection.java Fri Jul 13 03:39:24 2007 @@ -52,14 +52,13 @@ * If there are any elements already in the collection being decorated, they * are NOT transformed. * - * @param the type of the elements in the collection * @param coll the collection to decorate, must not be null * @param transformer the transformer to use for conversion, must not be null * @return a new transformed collection * @throws IllegalArgumentException if collection or transformer is null */ - public static Collection decorate(Collection coll, Transformer transformer) { - return new TransformedCollection(coll, transformer); + public static Collection decorate(Collection coll, Transformer transformer) { + return new TransformedCollection(coll, transformer); } //----------------------------------------------------------------------- @@ -73,7 +72,7 @@ * @param transformer the transformer to use for conversion, must not be null * @throws IllegalArgumentException if collection or transformer is null */ - protected TransformedCollection(Collection coll, Transformer transformer) { + protected TransformedCollection(Collection coll, Transformer transformer) { super(coll); if (transformer == null) { throw new IllegalArgumentException("Transformer must not be null"); @@ -89,8 +88,8 @@ * @param object the object to transform * @return a transformed object */ - protected E transform(E object) { - return transformer.transform(object); + protected E transform(Object object) { + return transformer.transform((E) object); } /** @@ -101,23 +100,21 @@ * @param coll the collection to transform * @return a transformed object */ - protected Collection transform(Collection coll) { - List list = new ArrayList(coll.size()); - for (E item : coll) { + protected Collection transform(Collection coll) { + List list = new ArrayList(coll.size()); + for (Object item : coll) { list.add(transform(item)); } return list; } //----------------------------------------------------------------------- - public boolean add(E object) { - object = transform(object); - return decorated().add(object); + public boolean add(Object object) { + return decorated().add(transform(object)); } - public boolean addAll(Collection coll) { - coll = transform(coll); - return decorated().addAll(coll); + public boolean addAll(Collection coll) { + return decorated().addAll(transform(coll)); } } Modified: jakarta/commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/iterators/AbstractListIteratorDecorator.java URL: http://svn.apache.org/viewvc/jakarta/commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/iterators/AbstractListIteratorDecorator.java?view=diff&rev=555925&r1=555924&r2=555925 ============================================================================== --- jakarta/commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/iterators/AbstractListIteratorDecorator.java (original) +++ jakarta/commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/iterators/AbstractListIteratorDecorator.java Fri Jul 13 03:39:24 2007 @@ -29,10 +29,10 @@ * @author Rodney Waldhoff * @author Stephen Colebourne */ -public class AbstractListIteratorDecorator implements ListIterator { +public class AbstractListIteratorDecorator implements ListIterator { /** The iterator being decorated */ - protected final ListIterator iterator; + protected final ListIterator iterator; //----------------------------------------------------------------------- /** @@ -41,7 +41,7 @@ * @param iterator the iterator to decorate, must not be null * @throws IllegalArgumentException if the collection is null */ - public AbstractListIteratorDecorator(ListIterator iterator) { + public AbstractListIteratorDecorator(ListIterator iterator) { super(); if (iterator == null) { throw new IllegalArgumentException("ListIterator must not be null"); @@ -54,7 +54,7 @@ * * @return the decorated iterator */ - protected ListIterator getListIterator() { + protected ListIterator getListIterator() { return iterator; } @@ -63,7 +63,7 @@ return iterator.hasNext(); } - public Object next() { + public E next() { return iterator.next(); } @@ -75,7 +75,7 @@ return iterator.hasPrevious(); } - public Object previous() { + public E previous() { return iterator.previous(); } @@ -87,11 +87,11 @@ iterator.remove(); } - public void set(Object obj) { + public void set(E obj) { iterator.set(obj); } - public void add(Object obj) { + public void add(E obj) { iterator.add(obj); } Modified: jakarta/commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/list/PredicatedList.java URL: http://svn.apache.org/viewvc/jakarta/commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/list/PredicatedList.java?view=diff&rev=555925&r1=555924&r2=555925 ============================================================================== --- jakarta/commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/list/PredicatedList.java (original) +++ jakarta/commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/list/PredicatedList.java Fri Jul 13 03:39:24 2007 @@ -16,15 +16,14 @@ */ package org.apache.commons.collections.list; -import java.util.Collection; -import java.util.Iterator; -import java.util.List; -import java.util.ListIterator; - import org.apache.commons.collections.Predicate; import org.apache.commons.collections.collection.PredicatedCollection; import org.apache.commons.collections.iterators.AbstractListIteratorDecorator; +import java.util.Collection; +import java.util.List; +import java.util.ListIterator; + /** * Decorates another List to validate that all additions * match a specified predicate. @@ -44,7 +43,7 @@ * @author Stephen Colebourne * @author Paul Jack */ -public class PredicatedList extends PredicatedCollection implements List { +public class PredicatedList extends PredicatedCollection implements List { /** Serialization version */ private static final long serialVersionUID = -5722039223898659102L; @@ -57,11 +56,12 @@ * * @param list the list to decorate, must not be null * @param predicate the predicate to use for validation, must not be null + * @return the decorated list * @throws IllegalArgumentException if list or predicate is null * @throws IllegalArgumentException if the list contains invalid elements */ - public static List decorate(List list, Predicate predicate) { - return new PredicatedList(list, predicate); + public static List decorate(List list, Predicate predicate) { + return new PredicatedList(list, predicate); } //----------------------------------------------------------------------- @@ -76,7 +76,7 @@ * @throws IllegalArgumentException if list or predicate is null * @throws IllegalArgumentException if the list contains invalid elements */ - protected PredicatedList(List list, Predicate predicate) { + protected PredicatedList(List list, Predicate predicate) { super(list, predicate); } @@ -85,12 +85,12 @@ * * @return the decorated list */ - protected List decorated() { - return (List) super.decorated(); + protected List decorated() { + return (List) super.decorated(); } //----------------------------------------------------------------------- - public Object get(int index) { + public E get(int index) { return decorated().get(index); } @@ -102,56 +102,56 @@ return decorated().lastIndexOf(object); } - public Object remove(int index) { + public E remove(int index) { return decorated().remove(index); } //----------------------------------------------------------------------- - public void add(int index, Object object) { + public void add(int index, E object) { validate(object); decorated().add(index, object); } - public boolean addAll(int index, Collection coll) { - for (Iterator it = coll.iterator(); it.hasNext(); ) { - validate(it.next()); + public boolean addAll(int index, Collection coll) { + for (E aColl : coll) { + validate(aColl); } return decorated().addAll(index, coll); } - public ListIterator listIterator() { + public ListIterator listIterator() { return listIterator(0); } - public ListIterator listIterator(int i) { + public ListIterator listIterator(int i) { return new PredicatedListIterator(decorated().listIterator(i)); } - public Object set(int index, Object object) { + public E set(int index, E object) { validate(object); return decorated().set(index, object); } - public List subList(int fromIndex, int toIndex) { - List sub = decorated().subList(fromIndex, toIndex); - return new PredicatedList(sub, predicate); + public List subList(int fromIndex, int toIndex) { + List sub = decorated().subList(fromIndex, toIndex); + return new PredicatedList(sub, predicate); } /** * Inner class Iterator for the PredicatedList */ - protected class PredicatedListIterator extends AbstractListIteratorDecorator { + protected class PredicatedListIterator extends AbstractListIteratorDecorator { - protected PredicatedListIterator(ListIterator iterator) { + protected PredicatedListIterator(ListIterator iterator) { super(iterator); } - public void add(Object object) { + public void add(E object) { validate(object); iterator.add(object); } - public void set(Object object) { + public void set(E object) { validate(object); iterator.set(object); } Modified: jakarta/commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/list/SynchronizedList.java URL: http://svn.apache.org/viewvc/jakarta/commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/list/SynchronizedList.java?view=diff&rev=555925&r1=555924&r2=555925 ============================================================================== --- jakarta/commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/list/SynchronizedList.java (original) +++ jakarta/commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/list/SynchronizedList.java Fri Jul 13 03:39:24 2007 @@ -35,7 +35,7 @@ * * @author Stephen Colebourne */ -public class SynchronizedList extends SynchronizedCollection implements List { +public class SynchronizedList extends SynchronizedCollection implements List { /** Serialization version */ private static final long serialVersionUID = -1403835447328619437L; @@ -46,8 +46,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 SynchronizedList(list); + public static List decorate(List list) { + return new SynchronizedList(list); } //----------------------------------------------------------------------- @@ -57,7 +57,7 @@ * @param list the list to decorate, must not be null * @throws IllegalArgumentException if list is null */ - protected SynchronizedList(List list) { + protected SynchronizedList(List list) { super(list); } @@ -68,7 +68,7 @@ * @param lock the lock to use, must not be null * @throws IllegalArgumentException if list is null */ - protected SynchronizedList(List list, Object lock) { + protected SynchronizedList(List list, Object lock) { super(list, lock); } @@ -77,24 +77,24 @@ * * @return the decorated list */ - protected List getList() { - return (List) collection; + protected List getList() { + return (List) collection; } //----------------------------------------------------------------------- - public void add(int index, Object object) { + public void add(int index, E object) { synchronized (lock) { getList().add(index, object); } } - public boolean addAll(int index, Collection coll) { + public boolean addAll(int index, Collection coll) { synchronized (lock) { return getList().addAll(index, coll); } } - public Object get(int index) { + public E get(int index) { synchronized (lock) { return getList().get(index); } @@ -140,24 +140,24 @@ return getList().listIterator(index); } - public Object remove(int index) { + public E remove(int index) { synchronized (lock) { return getList().remove(index); } } - public Object set(int index, Object object) { + public E set(int index, E object) { synchronized (lock) { return getList().set(index, object); } } - public List subList(int fromIndex, int toIndex) { + public List subList(int fromIndex, int toIndex) { synchronized (lock) { - List list = getList().subList(fromIndex, toIndex); + List list = getList().subList(fromIndex, toIndex); // the lock is passed into the constructor here to ensure that the sublist is // synchronized on the same lock as the parent list - return new SynchronizedList(list, lock); + return new SynchronizedList(list, lock); } } Modified: jakarta/commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/set/PredicatedSet.java URL: http://svn.apache.org/viewvc/jakarta/commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/set/PredicatedSet.java?view=diff&rev=555925&r1=555924&r2=555925 ============================================================================== --- jakarta/commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/set/PredicatedSet.java (original) +++ jakarta/commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/set/PredicatedSet.java Fri Jul 13 03:39:24 2007 @@ -40,7 +40,7 @@ * @author Stephen Colebourne * @author Paul Jack */ -public class PredicatedSet extends PredicatedCollection implements Set { +public class PredicatedSet extends PredicatedCollection implements Set { /** Serialization version */ private static final long serialVersionUID = -684521469108685117L; @@ -53,11 +53,12 @@ * * @param set the set to decorate, must not be null * @param predicate the predicate to use for validation, must not be null + * @return a decorated set * @throws IllegalArgumentException if set or predicate is null * @throws IllegalArgumentException if the set contains invalid elements */ - public static Set decorate(Set set, Predicate predicate) { - return new PredicatedSet(set, predicate); + public static Set decorate(Set set, Predicate predicate) { + return new PredicatedSet(set, predicate); } //----------------------------------------------------------------------- @@ -72,7 +73,7 @@ * @throws IllegalArgumentException if set or predicate is null * @throws IllegalArgumentException if the set contains invalid elements */ - protected PredicatedSet(Set set, Predicate predicate) { + protected PredicatedSet(Set set, Predicate predicate) { super(set, predicate); } @@ -81,8 +82,8 @@ * * @return the decorated set */ - protected Set decorated() { - return (Set) super.decorated(); + protected Set decorated() { + return (Set) super.decorated(); } } Modified: jakarta/commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/set/PredicatedSortedSet.java URL: http://svn.apache.org/viewvc/jakarta/commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/set/PredicatedSortedSet.java?view=diff&rev=555925&r1=555924&r2=555925 ============================================================================== --- jakarta/commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/set/PredicatedSortedSet.java (original) +++ jakarta/commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/set/PredicatedSortedSet.java Fri Jul 13 03:39:24 2007 @@ -40,7 +40,7 @@ * @author Stephen Colebourne * @author Paul Jack */ -public class PredicatedSortedSet extends PredicatedSet implements SortedSet { +public class PredicatedSortedSet extends PredicatedSet implements SortedSet { /** Serialization version */ private static final long serialVersionUID = -9110948148132275052L; @@ -53,11 +53,12 @@ * * @param set the set to decorate, must not be null * @param predicate the predicate to use for validation, must not be null + * @return a new predicated sorted set. * @throws IllegalArgumentException if set or predicate is null * @throws IllegalArgumentException if the set contains invalid elements */ - public static SortedSet decorate(SortedSet set, Predicate predicate) { - return new PredicatedSortedSet(set, predicate); + public static SortedSet decorate(SortedSet set, Predicate predicate) { + return new PredicatedSortedSet(set, predicate); } //----------------------------------------------------------------------- @@ -72,7 +73,7 @@ * @throws IllegalArgumentException if set or predicate is null * @throws IllegalArgumentException if the set contains invalid elements */ - protected PredicatedSortedSet(SortedSet set, Predicate predicate) { + protected PredicatedSortedSet(SortedSet set, Predicate predicate) { super(set, predicate); } @@ -81,36 +82,36 @@ * * @return the decorated sorted set */ - protected SortedSet decorated() { - return (SortedSet) super.decorated(); + protected SortedSet decorated() { + return (SortedSet) super.decorated(); } //----------------------------------------------------------------------- - public Comparator comparator() { + public Comparator comparator() { return decorated().comparator(); } - public Object first() { + public E first() { return decorated().first(); } - public Object last() { + public E last() { return decorated().last(); } - public SortedSet subSet(Object fromElement, Object toElement) { - SortedSet sub = decorated().subSet(fromElement, toElement); - return new PredicatedSortedSet(sub, predicate); + public SortedSet subSet(E fromElement, E toElement) { + SortedSet sub = decorated().subSet(fromElement, toElement); + return new PredicatedSortedSet(sub, predicate); } - public SortedSet headSet(Object toElement) { - SortedSet sub = decorated().headSet(toElement); - return new PredicatedSortedSet(sub, predicate); + public SortedSet headSet(E toElement) { + SortedSet sub = decorated().headSet(toElement); + return new PredicatedSortedSet(sub, predicate); } - public SortedSet tailSet(Object fromElement) { - SortedSet sub = decorated().tailSet(fromElement); - return new PredicatedSortedSet(sub, predicate); + public SortedSet tailSet(E fromElement) { + SortedSet sub = decorated().tailSet(fromElement); + return new PredicatedSortedSet(sub, predicate); } } Modified: jakarta/commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/set/SynchronizedSet.java URL: http://svn.apache.org/viewvc/jakarta/commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/set/SynchronizedSet.java?view=diff&rev=555925&r1=555924&r2=555925 ============================================================================== --- jakarta/commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/set/SynchronizedSet.java (original) +++ jakarta/commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/set/SynchronizedSet.java Fri Jul 13 03:39:24 2007 @@ -33,7 +33,7 @@ * * @author Stephen Colebourne */ -public class SynchronizedSet extends SynchronizedCollection implements Set { +public class SynchronizedSet extends SynchronizedCollection implements Set { /** Serialization version */ private static final long serialVersionUID = -8304417378626543635L; @@ -44,8 +44,8 @@ * @param set the set to decorate, must not be null * @throws IllegalArgumentException if set is null */ - public static Set decorate(Set set) { - return new SynchronizedSet(set); + public static Set decorate(Set set) { + return new SynchronizedSet(set); } //----------------------------------------------------------------------- @@ -55,7 +55,7 @@ * @param set the set to decorate, must not be null * @throws IllegalArgumentException if set is null */ - protected SynchronizedSet(Set set) { + protected SynchronizedSet(Set set) { super(set); } @@ -66,7 +66,7 @@ * @param lock the lock object to use, must not be null * @throws IllegalArgumentException if set is null */ - protected SynchronizedSet(Set set, Object lock) { + protected SynchronizedSet(Set set, Object lock) { super(set, lock); } Modified: jakarta/commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/set/SynchronizedSortedSet.java URL: http://svn.apache.org/viewvc/jakarta/commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/set/SynchronizedSortedSet.java?view=diff&rev=555925&r1=555924&r2=555925 ============================================================================== --- jakarta/commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/set/SynchronizedSortedSet.java (original) +++ jakarta/commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/set/SynchronizedSortedSet.java Fri Jul 13 03:39:24 2007 @@ -34,7 +34,7 @@ * * @author Stephen Colebourne */ -public class SynchronizedSortedSet extends SynchronizedCollection implements SortedSet { +public class SynchronizedSortedSet extends SynchronizedCollection implements SortedSet { /** Serialization version */ private static final long serialVersionUID = 2775582861954500111L; @@ -45,8 +45,8 @@ * @param set the set to decorate, must not be null * @throws IllegalArgumentException if set is null */ - public static SortedSet decorate(SortedSet set) { - return new SynchronizedSortedSet(set); + public static SortedSet decorate(SortedSet set) { + return new SynchronizedSortedSet(set); } //----------------------------------------------------------------------- @@ -56,7 +56,7 @@ * @param set the set to decorate, must not be null * @throws IllegalArgumentException if set is null */ - protected SynchronizedSortedSet(SortedSet set) { + protected SynchronizedSortedSet(SortedSet set) { super(set); } @@ -67,7 +67,7 @@ * @param lock the lock object to use, must not be null * @throws IllegalArgumentException if set is null */ - protected SynchronizedSortedSet(SortedSet set, Object lock) { + protected SynchronizedSortedSet(SortedSet set, Object lock) { super(set, lock); } @@ -76,12 +76,12 @@ * * @return the decorated set */ - protected SortedSet getSortedSet() { - return (SortedSet) collection; + protected SortedSet getSortedSet() { + return (SortedSet) collection; } //----------------------------------------------------------------------- - public SortedSet subSet(Object fromElement, Object toElement) { + public SortedSet subSet(E fromElement, E toElement) { synchronized (lock) { SortedSet set = getSortedSet().subSet(fromElement, toElement); // the lock is passed into the constructor here to ensure that the @@ -90,7 +90,7 @@ } } - public SortedSet headSet(Object toElement) { + public SortedSet headSet(E toElement) { synchronized (lock) { SortedSet set = getSortedSet().headSet(toElement); // the lock is passed into the constructor here to ensure that the @@ -99,7 +99,7 @@ } } - public SortedSet tailSet(Object fromElement) { + public SortedSet tailSet(E fromElement) { synchronized (lock) { SortedSet set = getSortedSet().tailSet(fromElement); // the lock is passed into the constructor here to ensure that the @@ -108,13 +108,13 @@ } } - public Object first() { + public E first() { synchronized (lock) { return getSortedSet().first(); } } - public Object last() { + public E last() { synchronized (lock) { return getSortedSet().last(); } Modified: jakarta/commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/set/UnmodifiableSortedSet.java URL: http://svn.apache.org/viewvc/jakarta/commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/set/UnmodifiableSortedSet.java?view=diff&rev=555925&r1=555924&r2=555925 ============================================================================== --- jakarta/commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/set/UnmodifiableSortedSet.java (original) +++ jakarta/commons/proper/collections/branches/collections_jdk5_branch/src/java/org/apache/commons/collections/set/UnmodifiableSortedSet.java Fri Jul 13 03:39:24 2007 @@ -37,8 +37,8 @@ * * @author Stephen Colebourne */ -public final class UnmodifiableSortedSet - extends AbstractSortedSetDecorator +public final class UnmodifiableSortedSet + extends AbstractSortedSetDecorator implements Unmodifiable, Serializable { /** Serialization version */ @@ -50,7 +50,7 @@ * @param set the set to decorate, must not be null * @throws IllegalArgumentException if set is null */ - public static SortedSet decorate(SortedSet set) { + public static SortedSet decorate(SortedSet set) { if (set instanceof Unmodifiable) { return set; } @@ -88,7 +88,7 @@ * @param set the set to decorate, must not be null * @throws IllegalArgumentException if set is null */ - private UnmodifiableSortedSet(SortedSet set) { + private UnmodifiableSortedSet(SortedSet set) { super(set); } @@ -97,11 +97,11 @@ 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 coll) { throw new UnsupportedOperationException(); } @@ -113,27 +113,27 @@ 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 SortedSet subSet(Object fromElement, Object toElement) { - SortedSet sub = decorated().subSet(fromElement, toElement); + public SortedSet subSet(E fromElement, E toElement) { + SortedSet sub = decorated().subSet(fromElement, toElement); return new UnmodifiableSortedSet(sub); } - public SortedSet headSet(Object toElement) { - SortedSet sub = decorated().headSet(toElement); + public SortedSet headSet(E toElement) { + SortedSet sub = decorated().headSet(toElement); return new UnmodifiableSortedSet(sub); } - public SortedSet tailSet(Object fromElement) { - SortedSet sub = decorated().tailSet(fromElement); + public SortedSet tailSet(E fromElement) { + SortedSet sub = decorated().tailSet(fromElement); return new UnmodifiableSortedSet(sub); } Modified: jakarta/commons/proper/collections/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/TestListUtils.java URL: http://svn.apache.org/viewvc/jakarta/commons/proper/collections/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/TestListUtils.java?view=diff&rev=555925&r1=555924&r2=555925 ============================================================================== --- jakarta/commons/proper/collections/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/TestListUtils.java (original) +++ jakarta/commons/proper/collections/branches/collections_jdk5_branch/src/test/org/apache/commons/collections/TestListUtils.java Fri Jul 13 03:39:24 2007 @@ -19,6 +19,7 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; +import java.util.Collections; import java.util.List; import junit.framework.Test; @@ -44,7 +45,7 @@ private static final String x = "x"; private String[] fullArray; - private List fullList; + private List fullList; public TestListUtils(String name) { super(name); @@ -62,8 +63,54 @@ public void testNothing() { } - - public void testpredicatedList() { + + /** + * Tests intersecting a non-empty list with an empty list. + */ + public void testIntersectNonEmptyWithEmptyList() { + final List empty = Collections.EMPTY_LIST; + assertTrue("result not empty", ListUtils.intersection(empty, fullList).isEmpty()); + } + + /** + * Tests intersecting a non-empty list with an empty list. + */ + public void testIntersectEmptyWithEmptyList() { + final List empty = Collections.EMPTY_LIST; + assertTrue("result not empty", ListUtils.intersection(empty, empty).isEmpty()); + } + + /** + * Tests intersecting a non-empty list with an subset of iteself. + */ + public void testIntersectNonEmptySubset() { + // create a copy + final List other = new ArrayList(fullList); + + // remove a few items + assertNotNull(other.remove(0)); + assertNotNull(other.remove(1)); + + // make sure the intersection is equal to the copy + assertEquals(other, ListUtils.intersection(fullList, other)); + } + + /** + * Tests intersecting a non-empty list with an subset of iteself. + */ + public void testIntersectListWithNoOverlapAndDifferentTypes() { + final List other = Arrays.asList(1, 23); + assertTrue(ListUtils.intersection(fullList, other).isEmpty()); + } + + /** + * Tests intersecting a non-empty list with iteself. + */ + public void testIntersectListWithSelf() { + assertEquals(fullList, ListUtils.intersection(fullList, fullList)); + } + + public void testPredicatedList() { Predicate predicate = new Predicate() { public boolean evaluate(Object o) { return o instanceof String; --------------------------------------------------------------------- To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org For additional commands, e-mail: commons-dev-help@jakarta.apache.org