net.sf.aguacate.function.spi.impl.FunctionResponseJson Maven / Gradle / Ivy
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);
}
}