/** * Returns a predicated (validating) set backed by the given 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 set to predicate, must not be null * @param predicate the predicate for the set, must not be null * @return a predicated set backed by the given set * @throws IllegalArgumentException if the Set or Predicate is null */ public static Set predicatedSet(Set set, Predicate predicate) { return PredicatedSet.decorate(set, predicate); }
/** * Factory method to create a predicated (validating) 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 Set decorate(Set set, Predicate predicate) { return new PredicatedSet(set, predicate); }
/** * Gets the set being decorated. * * @return the decorated set */ protected Set getSet() { return (Set) getCollection(); }
public void testGetSet() { Set set = makeTestSet(); assertTrue("returned set should not be null", ((PredicatedSet) set).getSet() != null); }
/** * Returns a predicated (validating) set backed by the given 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 set to predicate, must not be null * @param predicate the predicate for the set, must not be null * @return a predicated set backed by the given set * @throws IllegalArgumentException if the Set or Predicate is null */ public static Set predicatedSet(Set set, Predicate predicate) { return PredicatedSet.decorate(set, predicate); }
/** * Factory method to create a predicated (validating) 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 Set decorate(Set set, Predicate predicate) { return new PredicatedSet(set, predicate); }
/** * Gets the set being decorated. * * @return the decorated set */ protected Set getSet() { return (Set) getCollection(); }
protected Set decorateSet(Set set, Predicate predicate) { return PredicatedSet.decorate(set, predicate); }
/** * Factory method to create a typed 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 Set decorate(Set set, Class type) { return new PredicatedSet(set, InstanceofPredicate.getInstance(type)); }
/** * Gets the set being decorated. * * @return the decorated set */ protected Set getSet() { return (Set) getCollection(); }
/** * Returns a predicated (validating) set backed by the given 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 set to predicate, must not be null * @param predicate the predicate for the set, must not be null * @return a predicated set backed by the given set * @throws IllegalArgumentException if the Set or Predicate is null */ public static Set predicatedSet(Set set, Predicate predicate) { return PredicatedSet.decorate(set, predicate); }
/** * Factory method to create a typed 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 Set decorate(Set set, Class type) { return new PredicatedSet(set, InstanceofPredicate.getInstance(type)); }
/** * Gets the set being decorated. * * @return the decorated set */ protected Set getSet() { return (Set) getCollection(); }
/** * Returns a predicated (validating) set backed by the given 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 set to predicate, must not be null * @param predicate the predicate for the set, must not be null * @return a predicated set backed by the given set * @throws IllegalArgumentException if the Set or Predicate is null */ public static Set predicatedSet(Set set, Predicate predicate) { return PredicatedSet.decorate(set, predicate); }
/** * Factory method to create a predicated (validating) 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 Set decorate(Set set, Predicate predicate) { return new PredicatedSet(set, predicate); }
/** * Gets the set being decorated. * * @return the decorated set */ protected Set getSet() { return (Set) getCollection(); }
/** * Returns a predicated (validating) set backed by the given 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 set to predicate, must not be null * @param predicate the predicate for the set, must not be null * @return a predicated set backed by the given set * @throws IllegalArgumentException if the Set or Predicate is null */ public static Set predicatedSet(Set set, Predicate predicate) { return PredicatedSet.decorate(set, predicate); }
/** * Factory method to create a predicated (validating) 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 Set decorate(Set set, Predicate predicate) { return new PredicatedSet(set, predicate); }
/** * Gets the set being decorated. * * @return the decorated set */ protected Set getSet() { return (Set) getCollection(); }
/** * Returns a predicated (validating) set backed by the given 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 set to predicate, must not be null * @param predicate the predicate for the set, must not be null * @return a predicated set backed by the given set * @throws IllegalArgumentException if the Set or Predicate is null */ public static Set predicatedSet(Set set, Predicate predicate) { return PredicatedSet.decorate(set, predicate); }