package foam.dao;

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

public class RemoveSink {

  public RemoveSink(final DAO dao) {
    final X x = ((AbstractDAO) dao).getX();
    dao.select_(x, new AbstractSink() {
      @Override
      public void put(FObject obj, Detachable sub) {
        dao.remove_(x, obj);
      }
    }, 0, AbstractDAO.MAX_SAFE_INTEGER,null, null);
  }

  public RemoveSink(final DAO dao, long skip, long limit, Comparator order, Predicate predicate) {
    final X x = ((AbstractDAO) dao).getX();
    dao.select_(x, new AbstractSink() {
      @Override
      public void put(FObject obj, Detachable sub) {
        dao.remove_(x, obj);
      }
    }, skip, limit, order, predicate);
  }
}

@@ -187,17 +187,55 @@
 oveSink 
-%7B
+implements Sink %7B%0A%0A  protected DAO dao;
 %0A%0A  publ
@@ -244,30 +244,24 @@
  RemoveSink(
-final 
 DAO dao) %7B%0A 
@@ -255,24 +255,105 @@
 (DAO dao) %7B%0A
+    dao = dao;%0A  %7D%0A%0A  @Override%0A  public void put(FObject obj, Detachable sub) %7B%0A
     final X 
@@ -593,193 +593,116 @@
 %0A%0A  
-public RemoveSink(final DAO dao, long skip, long limit, Comparator order, Predicate predicate
+@Override%0A  public void remove(FObject obj, Detachable sub
 ) %7B%0A
+%0A
   
-  final X x = ((AbstractDAO) dao).getX();%0A    dao.select_(x, new AbstractSink
+%7D%0A%0A  @Override%0A  public void eof
 () %7B%0A
+%0A
   
-  
+%7D%0A%0A
   @O
@@ -701,36 +701,32 @@
  %7D%0A%0A  @Override%0A
-    
   public void pu
@@ -723,33 +723,22 @@
 ic void 
-put(FObject obj, 
+reset(
 Detachab
@@ -751,83 +751,8 @@
 ) %7B%0A
-        dao.remove_(x, obj);%0A      %7D%0A    %7D, skip, limit, order, predicate);
 %0A  %7D

make removesink implement sink