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

com.groupbyinc.common.jackson.jq.internal.tree.FormattingFilter Maven / Gradle / Ivy

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

import java.util.Collections;
import java.util.List;

import net.thisptr.jackson.jq.Function;
import net.thisptr.jackson.jq.JsonQuery;
import net.thisptr.jackson.jq.Scope;
import net.thisptr.jackson.jq.exception.JsonQueryException;

import com.fasterxml.jackson.databind.JsonNode;

public class FormattingFilter extends JsonQuery {
	private String name;

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

	@Override
	public List apply(final Scope scope, final JsonNode in) throws JsonQueryException {
		final Function f = scope.getFunction("@" + name, 0);
		if (f == null)
			throw new JsonQueryException("Formatting operator @" + name + " does not exist");
		return f.apply(scope, Collections. emptyList(), in);
	}

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




© 2015 - 2024 Weber Informatics LLC | Privacy Policy