
Replaced gel with grel in other places in the code base while maintaining backward compatibility. Changed layout in expression preview dialog to accommodate long GREL name. git-svn-id: http://google-refine.googlecode.com/svn/trunk@1442 7d457c2a-affb-35e4-300a-418c747d4874
35 lines
1.1 KiB
Java
35 lines
1.1 KiB
Java
package com.google.refine.expr.functions.math;
|
|
|
|
import java.util.Properties;
|
|
|
|
import org.json.JSONException;
|
|
import org.json.JSONWriter;
|
|
|
|
import com.google.refine.expr.EvalError;
|
|
import com.google.refine.grel.ControlFunctionRegistry;
|
|
import com.google.refine.grel.Function;
|
|
|
|
public class Min implements Function {
|
|
|
|
public Object call(Properties bindings, Object[] args) {
|
|
if (args.length == 2 &&
|
|
args[0] != null && args[0] instanceof Number &&
|
|
args[1] != null && args[1] instanceof Number) {
|
|
return Math.min(
|
|
((Number) args[0]).doubleValue(),
|
|
((Number) args[1]).doubleValue());
|
|
}
|
|
return new EvalError(ControlFunctionRegistry.getFunctionName(this) + " expects 2 numbers");
|
|
}
|
|
|
|
public void write(JSONWriter writer, Properties options)
|
|
throws JSONException {
|
|
|
|
writer.object();
|
|
writer.key("description"); writer.value("Returns the smaller of two numbers");
|
|
writer.key("params"); writer.value("number a, number b");
|
|
writer.key("returns"); writer.value("number");
|
|
writer.endObject();
|
|
}
|
|
}
|