@Override public boolean test(Object owner) { for (Criteria c : expressions) { if (c.test(owner)) { return true; } } return false; }
public static <T> List<T> filter(Collection<T> items, Criteria exp) { if (items.size() == 0) { return Collections.EMPTY_LIST; } List<T> results = new ArrayList<>(); for (T item : items) { if (exp.test(item)) { results.add(item); } } return results; }
public static boolean test(Object obj, Criteria exp) { return exp.test(obj); }