Exemplo n.º 1
0
  @Override
  public BigDecimal evaluate(QueryEval eval) {
    Object firstValue = multiplyExprs[0].evaluate(eval);
    BigDecimal result = new BigDecimal(firstValue.toString());

    for (int i = 1; i < multiplyExprs.length; i++) {
      Object nextValue = multiplyExprs[i].evaluate(eval);
      BigDecimal operand = new BigDecimal(nextValue.toString());
      result = operators.get(i - 1) ? result.add(operand) : result.subtract(operand);
    }

    return result;
  }