@Test public void calculate2() { String formula = "3 * b / c"; BigDecimal value = Calculator .calculate(formula, MoreObjects.mapOf("b", 4.2, "c", 2.3), 2); Assert.assertEquals(new BigDecimal("3") .multiply(new BigDecimal("4.2").divide(new BigDecimal("2.3"), 5, RoundingMode.HALF_DOWN)) .setScale(2, RoundingMode.HALF_DOWN), value); }
public BigDecimal calculate(String formula) { return calculate(formula, null); }
Calculator { public BigDecimal calculate(String formula) { return calculate(formula, null); } }
Calculator { public BigDecimal calculate(String formula) { return calculate(formula, null); }  }
Calculator { public BigDecimal calculate(String formula) { return calculate(formula, null); }  BigDecimal calculate(String formula); BigDecimal calculate(String formula, Object data); BigDecimal calculate(String formula, Object data, int scale); }
Calculator { public BigDecimal calculate(String formula) { return calculate(formula, null); }  BigDecimal calculate(String formula); BigDecimal calculate(String formula, Object data); BigDecimal calculate(String formula, Object data, int scale);  }