1 16 package org.apache.commons.collections.set; 17 18 import java.util.Comparator ; 19 import java.util.SortedSet ; 20 21 import org.apache.commons.collections.Predicate; 22 23 42 public class PredicatedSortedSet extends PredicatedSet implements SortedSet { 43 44 45 private static final long serialVersionUID = -9110948148132275052L; 46 47 58 public static SortedSet decorate(SortedSet set, Predicate predicate) { 59 return new PredicatedSortedSet(set, predicate); 60 } 61 62 74 protected PredicatedSortedSet(SortedSet set, Predicate predicate) { 75 super(set, predicate); 76 } 77 78 83 private SortedSet getSortedSet() { 84 return (SortedSet ) getCollection(); 85 } 86 87 public SortedSet subSet(Object fromElement, Object toElement) { 89 SortedSet sub = getSortedSet().subSet(fromElement, toElement); 90 return new PredicatedSortedSet(sub, predicate); 91 } 92 93 public SortedSet headSet(Object toElement) { 94 SortedSet sub = getSortedSet().headSet(toElement); 95 return new PredicatedSortedSet(sub, predicate); 96 } 97 98 public SortedSet tailSet(Object fromElement) { 99 SortedSet sub = getSortedSet().tailSet(fromElement); 100 return new PredicatedSortedSet(sub, predicate); 101 } 102 103 public Object first() { 104 return getSortedSet().first(); 105 } 106 107 public Object last() { 108 return getSortedSet().last(); 109 } 110 111 public Comparator comparator() { 112 return getSortedSet().comparator(); 113 } 114 115 } 116 | Popular Tags |