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
This commit is contained in:
parent
60425a423f
commit
c33b575cfc
|
@ -40,7 +40,7 @@ import org.apache.commons.collections.Predicate;
|
||||||
* @author Stephen Colebourne
|
* @author Stephen Colebourne
|
||||||
* @author Paul Jack
|
* @author Paul Jack
|
||||||
*/
|
*/
|
||||||
public class PredicatedSortedSet extends PredicatedSet implements SortedSet {
|
public class PredicatedSortedSet<E> extends PredicatedSet<E> implements SortedSet<E> {
|
||||||
|
|
||||||
/** Serialization version */
|
/** Serialization version */
|
||||||
private static final long serialVersionUID = -9110948148132275052L;
|
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 set the set to decorate, must not be null
|
||||||
* @param predicate the predicate to use for validation, 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 set or predicate is null
|
||||||
* @throws IllegalArgumentException if the set contains invalid elements
|
* @throws IllegalArgumentException if the set contains invalid elements
|
||||||
*/
|
*/
|
||||||
public static SortedSet decorate(SortedSet set, Predicate predicate) {
|
public static <T> SortedSet<T> decorate(SortedSet<T> set, Predicate<? super T> predicate) {
|
||||||
return new PredicatedSortedSet(set, predicate);
|
return new PredicatedSortedSet<T>(set, predicate);
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------
|
//-----------------------------------------------------------------------
|
||||||
|
@ -72,7 +73,7 @@ public class PredicatedSortedSet extends PredicatedSet implements SortedSet {
|
||||||
* @throws IllegalArgumentException if set or predicate is null
|
* @throws IllegalArgumentException if set or predicate is null
|
||||||
* @throws IllegalArgumentException if the set contains invalid elements
|
* @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);
|
super(set, predicate);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -81,36 +82,36 @@ public class PredicatedSortedSet extends PredicatedSet implements SortedSet {
|
||||||
*
|
*
|
||||||
* @return the decorated sorted set
|
* @return the decorated sorted set
|
||||||
*/
|
*/
|
||||||
private SortedSet getSortedSet() {
|
protected SortedSet<E> decorated() {
|
||||||
return (SortedSet) getCollection();
|
return (SortedSet<E>) super.decorated();
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------
|
//-----------------------------------------------------------------------
|
||||||
public SortedSet subSet(Object fromElement, Object toElement) {
|
public Comparator<? super E> comparator() {
|
||||||
SortedSet sub = getSortedSet().subSet(fromElement, toElement);
|
return decorated().comparator();
|
||||||
return new PredicatedSortedSet(sub, predicate);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public SortedSet headSet(Object toElement) {
|
public E first() {
|
||||||
SortedSet sub = getSortedSet().headSet(toElement);
|
return decorated().first();
|
||||||
return new PredicatedSortedSet(sub, predicate);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public SortedSet tailSet(Object fromElement) {
|
public E last() {
|
||||||
SortedSet sub = getSortedSet().tailSet(fromElement);
|
return decorated().last();
|
||||||
return new PredicatedSortedSet(sub, predicate);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Object first() {
|
public SortedSet<E> subSet(E fromElement, E toElement) {
|
||||||
return getSortedSet().first();
|
SortedSet<E> sub = decorated().subSet(fromElement, toElement);
|
||||||
|
return new PredicatedSortedSet<E>(sub, predicate);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Object last() {
|
public SortedSet<E> headSet(E toElement) {
|
||||||
return getSortedSet().last();
|
SortedSet<E> sub = decorated().headSet(toElement);
|
||||||
|
return new PredicatedSortedSet<E>(sub, predicate);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Comparator comparator() {
|
public SortedSet<E> tailSet(E fromElement) {
|
||||||
return getSortedSet().comparator();
|
SortedSet<E> sub = decorated().tailSet(fromElement);
|
||||||
|
return new PredicatedSortedSet<E>(sub, predicate);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue