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

net.sf.aguacate.function.spi.AbstractFunction1 Maven / Gradle / Ivy

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

import java.text.MessageFormat;
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.Parameter;

public abstract class AbstractFunction1 extends AbstractFunction {

	private final Parameter parameter;

	private final String message;

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

	@Override
	public FunctionEvalResult evaluate(FunctionContext functionContext, Map context) {
		Object value = context.get(parameter.getName());
		String msg = MessageFormat.format(message, value);
		return evaluate(functionContext, msg, value);
	}

	protected abstract FunctionEvalResult evaluate(FunctionContext functionContext, String msg, Object value);

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy