@Override public List<T> find(Collection<T> collection) throws QueryException { // new arraylist for result List<T> result = new ArrayList<T>(); for (T item : collection) { if (match(item, rootType)) { result.add(item); } } return result; }
@Override public int filter(Collection<T> collection) throws QueryException { // find items List<T> matched = new ArrayList<T>(); for (T item : collection) { if (match(item, rootType)) { matched.add(item); } } collection.clear(); collection.addAll(matched); return matched.size(); }
@SuppressWarnings({ "rawtypes", "unchecked" }) @Override public int filter(T rootObject, Class<?> childClass) throws QueryException { // retrieve underlying collection TypeInfo childType = rootType.getCollectionChild(childClass); if (childType == null || !(childType instanceof IteratableTypeInfo)) { return 0; } Collection collection = (Collection) childType.getAccessor().getValue(rootObject); // get the child type of the collection type TypeInfo ti = childType.getCollectionChild(childClass); List matched = new ArrayList(); for (Object item : collection) { if (match(item, ti)) { matched.add(item); } } collection.clear(); collection.addAll(matched); return matched.size(); }