You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
31 lines
1004 B
31 lines
1004 B
7 years ago
|
package com.fr.plugin;
|
||
|
|
||
|
import com.fr.general.FArray;
|
||
|
import com.fr.general.GeneralUtils;
|
||
|
import com.fr.intelli.record.Focus;
|
||
|
import com.fr.intelli.record.Original;
|
||
|
import com.fr.record.analyzer.EnableMetrics;
|
||
|
import com.fr.script.AbstractFunction;
|
||
|
import com.fr.stable.ArrayUtils;
|
||
|
import com.fr.stable.Primitive;
|
||
|
|
||
|
@EnableMetrics
|
||
|
public class MyAbs extends AbstractFunction {
|
||
|
|
||
|
@Focus(id = "com.fr.plugin.function.test", text = "Function description", source = Original.PLUGIN)
|
||
|
public Object run(Object[] args) {
|
||
|
int len = ArrayUtils.getLength(args);
|
||
|
if (len == 0) {
|
||
|
return Primitive.ERROR_VALUE;
|
||
|
} else if (len == 1) {
|
||
|
return Math.abs(GeneralUtils.objectToNumber(args[0]).doubleValue());
|
||
|
} else {
|
||
|
FArray<Double> result = new FArray<Double>();
|
||
|
for (Object arg : args) {
|
||
|
result.add(GeneralUtils.objectToNumber(arg).doubleValue());
|
||
|
}
|
||
|
}
|
||
|
return Primitive.ERROR_VALUE;
|
||
|
}
|
||
|
}
|