All Downloads are FREE. Search and download functionalities are using the official Maven repository.

net.thisptr.jackson.jq.internal.tree.matcher.matchers.ValueMatcher Maven / Gradle / Ivy

There is a newer version: 1.2.0
Show newest version
package net.thisptr.jackson.jq.internal.tree.matcher.matchers;

import java.util.List;
import java.util.Stack;

import com.fasterxml.jackson.databind.JsonNode;

import net.thisptr.jackson.jq.Scope;
import net.thisptr.jackson.jq.exception.JsonQueryException;
import net.thisptr.jackson.jq.internal.misc.Functional;
import net.thisptr.jackson.jq.internal.misc.Pair;
import net.thisptr.jackson.jq.internal.tree.matcher.PatternMatcher;
import net.thisptr.jackson.jq.path.Path;

public class ValueMatcher implements PatternMatcher {
	private String name;

	public ValueMatcher(final String name) {
		this.name = name;
	}

	@Override
	public void match(final Scope scope, final JsonNode in, final Functional.Consumer>> out, final Stack> accumulate) throws JsonQueryException {
		accumulate.push(Pair.of(name, in));
		out.accept(accumulate);
	}

	@Override
	public void matchWithPath(final Scope scope, final JsonNode in, final Path path, final MatchOutput output, final Stack accumulate) throws JsonQueryException {
		accumulate.push(new MatchWithPath(name, in, path));
		output.emit(accumulate);
	}

	@Override
	public String toString() {
		return "$" + name;
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy