/**
 * @license
 * Copyright 2017 The FOAM Authors. All Rights Reserved.
 * http://www.apache.org/licenses/LICENSE-2.0
 */

package foam.dao;

import foam.core.X;
import foam.mlang.predicate.Predicate;
import foam.mlang.order.Comparator;

public class FilteredDAO
  extends ProxyDAO
{
  protected Predicate predicate_;

  public FilteredDAO(Predicate predicate, DAO delegate) {
    predicate_ = predicate;
    setDelegate(delegate);
  }

  public FilteredDAO() {}

  public FilteredDAO setPredicate(Predicate predicate) {
    predicate_ = predicate;
    return this;
  }

  private Predicate getPredicate(Predicate arg) {
    return arg == null ? predicate_ : foam.mlang.MLang.AND(predicate_, arg);
  }

  @Override
  public Sink select_(X x, Sink s, long skip, long limit, Comparator order, Predicate predicate) {
    return super.select_(x, s, skip, limit, order, getPredicate(predicate));
  }

  @Override
  public void removeAll_(X x, long skip, long limit, Comparator order, Predicate predicate) {
    super.removeAll_(x, skip, limit, order, getPredicate(predicate));
  }
}

@@ -1069,11 +1069,142 @@
 e));%0A  %7D
+%0A%0A  @Override%0A  public void listen_(X x, Sink sink, Predicate predicate) %7B%0A    super.listen_(x, sink, getPredicate(predicate));%0A  %7D
 %0A%7D%0A

Implement listen_ in java FilteredDAO.