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

net.thisptr.jackson.jq.module.SimpleModule Maven / Gradle / Ivy

There is a newer version: 1.2.0
Show newest version
package net.thisptr.jackson.jq.module;

import java.util.Collections;
import java.util.HashMap;
import java.util.Map;

import net.thisptr.jackson.jq.Function;
import net.thisptr.jackson.jq.internal.annotations.Experimental;

@Experimental
public class SimpleModule implements Module {
	private final Map functions = new HashMap<>();

	public void addFunction(final String fname, final int nargs, final Function f) {
		addFunction(fname + "/" + nargs, f);
	}

	public void addFunction(final String fnameAndNarg, final Function f) {
		functions.put(fnameAndNarg, f);
	}

	public void addAllFunctions(final Map functions) {
		this.functions.putAll(functions);
	}

	@Override
	public Function getFunction(final String fname, final int nargs) {
		return functions.get(fname + "/" + nargs);
	}

	@Override
	public Map getAllFunctions() {
		return Collections.unmodifiableMap(functions);
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy