commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bay...@apache.org
Subject svn commit: r815099 - /commons/proper/collections/trunk/src/java/org/apache/commons/collections/set/PredicatedSortedSet.java
Date Tue, 15 Sep 2009 05:56:42 GMT
Author: bayard
Date: Tue Sep 15 05:56:42 2009
New Revision: 815099

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

Modified: commons/proper/collections/trunk/src/java/org/apache/commons/collections/set/PredicatedSortedSet.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/java/org/apache/commons/collections/set/PredicatedSortedSet.java?rev=815099&r1=815098&r2=815099&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/java/org/apache/commons/collections/set/PredicatedSortedSet.java
(original)
+++ commons/proper/collections/trunk/src/java/org/apache/commons/collections/set/PredicatedSortedSet.java
Tue Sep 15 05:56:42 2009
@@ -40,7 +40,7 @@
  * @author Stephen Colebourne
  * @author Paul Jack
  */
-public class PredicatedSortedSet extends PredicatedSet implements SortedSet {
+public class PredicatedSortedSet<E> extends PredicatedSet<E> implements SortedSet<E>
{
 
     /** 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 <T> SortedSet<T> decorate(SortedSet<T> set, Predicate<?
super T> predicate) {
+        return new PredicatedSortedSet<T>(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<E> set, Predicate<? super E> predicate)
{
         super(set, predicate);
     }
 
@@ -81,36 +82,36 @@
      * 
      * @return the decorated sorted set
      */
-    private SortedSet getSortedSet() {
-        return (SortedSet) getCollection();
+    protected SortedSet<E> decorated() {
+        return (SortedSet<E>) super.decorated();
     }
 
     //-----------------------------------------------------------------------
-    public SortedSet subSet(Object fromElement, Object toElement) {
-        SortedSet sub = getSortedSet().subSet(fromElement, toElement);
-        return new PredicatedSortedSet(sub, predicate);
+    public Comparator<? super E> 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<E> subSet(E fromElement, E toElement) {
+        SortedSet<E> sub = decorated().subSet(fromElement, toElement);
+        return new PredicatedSortedSet<E>(sub, predicate);
     }
 
-    public Object last() {
-        return getSortedSet().last();
+    public SortedSet<E> headSet(E toElement) {
+        SortedSet<E> sub = decorated().headSet(toElement);
+        return new PredicatedSortedSet<E>(sub, predicate);
     }
 
-    public Comparator comparator() {
-        return getSortedSet().comparator();
+    public SortedSet<E> tailSet(E fromElement) {
+        SortedSet<E> sub = decorated().tailSet(fromElement);
+        return new PredicatedSortedSet<E>(sub, predicate);
     }
 
 }



Mime
View raw message