List of usage examples for org.apache.commons.collections.functors AllPredicate getInstance
public static Predicate getInstance(Collection predicates)
From source file:net.sourceforge.fenixedu.presentationTier.util.CollectionFilter.java
public Set<T> filter(Set<T> elements) { Set<T> filtered;// w w w .j a v a2 s. c o m if (comparator == null) { filtered = new HashSet<T>(); } else { filtered = new TreeSet<T>(comparator); } final Set<Predicate> predicates = getPredicates(); if (predicates == null || predicates.isEmpty()) { filtered.addAll(elements); return Collections.unmodifiableSet(filtered); } Predicate predicate; if (predicates.size() == 1) { predicate = predicates.iterator().next(); } else { predicate = AllPredicate.getInstance(predicates); } for (T element : elements) { if (predicate.evaluate(element)) { filtered.add(element); } } return Collections.unmodifiableSet(filtered); }