package pt.utl.ist.fenix.tools.predicates; import java.util.ArrayList; import java.util.Collection; public class ResultCollection { private Predicate predicate; private Collection result; public ResultCollection(final Collection result, final Predicate predicate) { this.result = result; this.predicate = predicate; } public ResultCollection(final Predicate predicate) { this(new ArrayList(), predicate); } public Collection getResult() { return result; } private boolean add(T t) { return this.result.add(t); } public void condicionalAdd(T t) { if (predicate.eval(t)) { add(t); } } }