/** * Returns a predicated (validating) sorted set backed by the given sorted set. * <p> * Only objects that pass the test in the given predicate can be added to the set. * Trying to add an invalid object results in an IllegalArgumentException. * It is important not to use the original set after invoking this method, * as it is a backdoor for adding invalid objects. * * @param set the sorted set to predicate, must not be null * @param predicate the predicate for the sorted set, must not be null * @return a predicated sorted set backed by the given sorted set * @throws IllegalArgumentException if the Set or Predicate is null */ public static SortedSet predicatedSortedSet(SortedSet set, Predicate predicate) { return PredicatedSortedSet.decorate(set, predicate); }
public SortedSet headSet(Object toElement) { SortedSet sub = getSortedSet().headSet(toElement); return new PredicatedSortedSet(sub, predicate); }
/** * Gets the sorted set being decorated. * * @return the decorated sorted set */ private SortedSet getSortedSet() { return (SortedSet) getCollection(); }
public Object first() { return getSortedSet().first(); }
/** * Factory method to create a predicated (validating) sorted set. * <p> * If there are any elements already in the set being decorated, they * are validated. * * @param set the set to decorate, must not be null * @param predicate the predicate to use for validation, must not be null * @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 Object last() { return getSortedSet().last(); }
/** * Factory method to create a predicated (validating) sorted set. * <p> * If there are any elements already in the set being decorated, they * are validated. * * @param set the set to decorate, must not be null * @param predicate the predicate to use for validation, must not be null * @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 SortedSet tailSet(Object fromElement) { SortedSet sub = getSortedSet().tailSet(fromElement); return new PredicatedSortedSet(sub, predicate); }
/** * Returns a predicated (validating) sorted set backed by the given sorted set. * <p> * Only objects that pass the test in the given predicate can be added to the set. * Trying to add an invalid object results in an IllegalArgumentException. * It is important not to use the original set after invoking this method, * as it is a backdoor for adding invalid objects. * * @param set the sorted set to predicate, must not be null * @param predicate the predicate for the sorted set, must not be null * @return a predicated sorted set backed by the given sorted set * @throws IllegalArgumentException if the Set or Predicate is null */ public static SortedSet predicatedSortedSet(SortedSet set, Predicate predicate) { return PredicatedSortedSet.decorate(set, predicate); }
public Comparator comparator() { return getSortedSet().comparator(); }
/** * Factory method to create a typed sorted set. * <p> * If there are any elements already in the set being decorated, they * are validated. * * @param set the set to decorate, must not be null * @param type the type to allow into the collection, must not be null * @throws IllegalArgumentException if set or type is null * @throws IllegalArgumentException if the set contains invalid elements */ public static SortedSet decorate(SortedSet set, Class type) { return new PredicatedSortedSet(set, InstanceofPredicate.getInstance(type)); }
/** * Gets the sorted set being decorated. * * @return the decorated sorted set */ private SortedSet getSortedSet() { return (SortedSet) getCollection(); }
public SortedSet headSet(Object toElement) { SortedSet sub = getSortedSet().headSet(toElement); return new PredicatedSortedSet(sub, predicate); }
protected SortedSet makeTestSet() { return PredicatedSortedSet.decorate(new TreeSet(), testPredicate); }
public Object last() { return getSortedSet().last(); }
/** * Factory method to create a typed sorted set. * <p> * If there are any elements already in the set being decorated, they * are validated. * * @param set the set to decorate, must not be null * @param type the type to allow into the collection, must not be null * @throws IllegalArgumentException if set or type is null * @throws IllegalArgumentException if the set contains invalid elements */ public static SortedSet decorate(SortedSet set, Class type) { return new PredicatedSortedSet(set, InstanceofPredicate.getInstance(type)); }
/** * Gets the sorted set being decorated. * * @return the decorated sorted set */ private SortedSet getSortedSet() { return (SortedSet) getCollection(); }
public SortedSet tailSet(Object fromElement) { SortedSet sub = getSortedSet().tailSet(fromElement); return new PredicatedSortedSet(sub, predicate); }
public Set makeEmptySet() { return PredicatedSortedSet.decorate(new TreeSet(), truePredicate); }
public Comparator comparator() { return getSortedSet().comparator(); }