org.aksw.jenax.arq.aggregation.AccCondition Maven / Gradle / Ivy
The newest version!
package org.aksw.jenax.arq.aggregation;
import java.util.function.Predicate;
import org.aksw.commons.collector.domain.Accumulator;
public class AccCondition
implements Accumulator
{
protected Predicate predicate;
protected Accumulator subAcc;
public AccCondition(Predicate predicate, Accumulator subAcc) {
super();
this.predicate = predicate;
this.subAcc = subAcc;
}
@Override
public void accumulate(B binding, E env) {
boolean accept = predicate.test(binding);
if(accept) {
subAcc.accumulate(binding);;
}
}
@Override
public V getValue() {
V result = subAcc.getValue();
return result;
}
public static Accumulator create(Predicate predicate, Accumulator subAcc) {
Accumulator result = new AccCondition<>(predicate, subAcc);
return result;
}
}