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

net.sf.aguacate.function.spi.impl.FunctionResponseJson Maven / Gradle / Ivy

There is a newer version: 0.10.9
Show newest version
package net.sf.aguacate.function.spi.impl;

import java.util.Collection;
import java.util.Map;

import net.sf.aguacate.function.FunctionContext;
import net.sf.aguacate.function.FunctionEvalResult;
import net.sf.aguacate.function.spi.AbstractFunction;
import net.sf.aguacate.util.parameter.Parameter;

public class FunctionResponseJson extends AbstractFunction {

	private final Parameter parameter;

	public FunctionResponseJson(Collection methods, String name, Parameter parameter) {
		super(methods, name);
		this.parameter = parameter;
	}

	@Override
	public FunctionEvalResult evaluate(FunctionContext functionContext, Map context) {
		String parameterName = parameter.getName();
		Object object = parameter.calculateContext(context).get(parameterName);
		if (object == null) {
			functionContext.handleNotFound();
		} else {
			functionContext.handleOk(object);
		}
		return new FunctionEvalResult(null, null);
	}

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy