From c33b575cfca19782da1dcf6e3d587e8f2f7bcf87 Mon Sep 17 00:00:00 2001 From: Henri Yandell Date: Tue, 15 Sep 2009 05:56:42 +0000 Subject: [PATCH] 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 ------------------------------------------------------------------------ r471202 | scolebourne | 2006-11-04 06:21:44 -0800 (Sat, 04 Nov 2006) | 1 line Remove getCollection() - use covariant decorated() ------------------------------------------------------------------------ git-svn-id: https://svn.apache.org/repos/asf/commons/proper/collections/trunk@815099 13f79535-47bb-0310-9956-ffa450edef68 --- .../collections/set/PredicatedSortedSet.java | 43 ++++++++++--------- 1 file changed, 22 insertions(+), 21 deletions(-) diff --git a/src/java/org/apache/commons/collections/set/PredicatedSortedSet.java b/src/java/org/apache/commons/collections/set/PredicatedSortedSet.java index 7b9f4a98a..6527b074c 100644 --- a/src/java/org/apache/commons/collections/set/PredicatedSortedSet.java +++ b/src/java/org/apache/commons/collections/set/PredicatedSortedSet.java @@ -40,7 +40,7 @@ import org.apache.commons.collections.Predicate; * @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 @@ public class PredicatedSortedSet extends PredicatedSet implements SortedSet { * * @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 @@ public class PredicatedSortedSet extends PredicatedSet implements SortedSet { * @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 @@ public class PredicatedSortedSet extends PredicatedSet implements SortedSet { * * @return the decorated sorted set */ - private SortedSet getSortedSet() { - return (SortedSet) getCollection(); + protected SortedSet decorated() { + return (SortedSet) super.decorated(); } //----------------------------------------------------------------------- - public SortedSet subSet(Object fromElement, Object toElement) { - SortedSet sub = getSortedSet().subSet(fromElement, toElement); - return new PredicatedSortedSet(sub, predicate); + public Comparator comparator() { + return decorated().comparator(); } - public SortedSet headSet(Object toElement) { - SortedSet sub = getSortedSet().headSet(toElement); - return new PredicatedSortedSet(sub, predicate); + public E first() { + return decorated().first(); } - public SortedSet tailSet(Object fromElement) { - SortedSet sub = getSortedSet().tailSet(fromElement); - return new PredicatedSortedSet(sub, predicate); + public E last() { + return decorated().last(); } - public Object first() { - return getSortedSet().first(); + public SortedSet subSet(E fromElement, E toElement) { + SortedSet sub = decorated().subSet(fromElement, toElement); + return new PredicatedSortedSet(sub, predicate); } - public Object last() { - return getSortedSet().last(); + public SortedSet headSet(E toElement) { + SortedSet sub = decorated().headSet(toElement); + return new PredicatedSortedSet(sub, predicate); } - public Comparator comparator() { - return getSortedSet().comparator(); + public SortedSet tailSet(E fromElement) { + SortedSet sub = decorated().tailSet(fromElement); + return new PredicatedSortedSet(sub, predicate); } }