net.sf.aguacate.function.spi.impl.FunctionLiteralString Maven / Gradle / Ivy
package net.sf.aguacate.function.spi.impl;
import java.text.MessageFormat;
import java.util.Collection;
import java.util.List;
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.type.Str;
public class FunctionLiteralString extends AbstractFunction {
private final String outputName;
private final String[] outputContext;
private final FunctionEvalResult result;
private final String message;
public FunctionLiteralString(Collection methods, String name, String message, List outputContext,
String outputName, Object value) {
super(methods, name);
this.outputContext = Str.toArray(outputContext);
this.outputName = outputName;
this.result = new FunctionEvalResult(true, (String) value);
this.message = message;
}
@Override
public FunctionEvalResult evaluate(FunctionContext functionContext, Map context) {
logSuccess(MessageFormat.format(message, result.getData()));
return result;
}
@Override
public String[] getOutputContext() {
return outputContext;
}
@Override
public String getOutputName() {
return outputName;
}
}