net.thisptr.jackson.jq.internal.JsonPredicateFunction Maven / Gradle / Ivy
package net.thisptr.jackson.jq.internal;
import java.util.List;
import java.util.function.Predicate;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.node.BooleanNode;
import net.thisptr.jackson.jq.Expression;
import net.thisptr.jackson.jq.Function;
import net.thisptr.jackson.jq.PathOutput;
import net.thisptr.jackson.jq.Scope;
import net.thisptr.jackson.jq.Version;
import net.thisptr.jackson.jq.exception.JsonQueryException;
import net.thisptr.jackson.jq.path.Path;
public class JsonPredicateFunction implements Function {
private Predicate predicate;
public JsonPredicateFunction(final Predicate predicate) {
this.predicate = predicate;
}
@Override
public void apply(final Scope scope, final List args, final JsonNode in, final Path ipath, final PathOutput output, final Version version) throws JsonQueryException {
output.emit(BooleanNode.valueOf(predicate.test(in)), null);
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy