/** * Decorates the given list with validating behavior using the predicate. All accepted elements * are appended to the set. If the set already contains elements, they are validated. * <p> * The builder is not modified by this method, so it is possible to create more collections * or add more elements afterwards. Further changes will not propagate to the returned set. * * @param set the set to decorate, must not be null * @return the decorated set. * @throws NullPointerException if set is null * @throws IllegalArgumentException if set contains invalid elements */ public Set<E> createPredicatedSet(final Set<E> set) { if (set == null) { throw new NullPointerException("Set must not be null."); } final PredicatedSet<E> predicatedSet = PredicatedSet.predicatedSet(set, predicate); predicatedSet.addAll(accepted); return predicatedSet; }