27 lines
614 B
Plaintext
Executable File
27 lines
614 B
Plaintext
Executable File
package com.fp.common.formula.functions;
|
|
|
|
import java.math.BigDecimal;
|
|
import java.math.RoundingMode;
|
|
|
|
import com.fp.common.formula.AbstractFunction;
|
|
import com.fp.common.helper.Constant;
|
|
|
|
/**
|
|
* @author
|
|
*/
|
|
public class Percent extends AbstractFunction {
|
|
|
|
@Override
|
|
public int getNumberOfParameters() {
|
|
return 2;
|
|
}
|
|
|
|
@Override
|
|
public Object eval() throws Exception {
|
|
BigDecimal total = this.nextBigDecimalParameter();
|
|
BigDecimal value = this.nextBigDecimalParameter();
|
|
|
|
return value.multiply(Constant.BD_ONE_HUNDRED).divide(total, RoundingMode.HALF_UP);
|
|
}
|
|
|
|
} |