// 数值型
Expression exp = new Expression("(x + y)/2");
Map<String, BigDecimal> variables = new HashMap<String, BigDecimal>();
variables.put("x", new BigDecimal("4.32"));
variables.put("y", new BigDecimal("342.1"));
BigDecimal result = exp.eval(variables);
System.out.println(result);
// 布尔型
Expression ww = new Expression("( A && B ) || C ");
Map<String, BigDecimal> vs = new HashMap<String, BigDecimal>();
vs.put("A", new BigDecimal("0"));
vs.put("B", new BigDecimal("1"));
vs.put("C", new BigDecimal("1"));
System.out.println(ww.eval(vs));
// 布尔型
Expression dd = new Expression(" A > 200 ");
Map<String, BigDecimal> as = new HashMap<String, BigDecimal>();
as.put("A", new BigDecimal("12000"));
System.out.println(dd.eval(as));
需要eval.jar