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); } }