@Test public void testMixedDivision() { final Division exprMixed = new Division(new NumberLiteral(3, DUMMY_LINE_INFO), DEC_1_5, DUMMY_LINE_INFO); assertThat(ExpressionEvaluator.evaluate(exprMixed, new FormAnswers())).isExactlyInstanceOf(NumberValue.class); assertThat(ExpressionEvaluator.evaluate(exprMixed, new FormAnswers()).getNumber()).isEqualTo("2"); }
public static Value evaluate(final Expression expr, final FormAnswers variables) { return expr.accept(new ExpressionEvaluator(variables)); }
ExpressionEvaluator implements ExpressionVisitor<Value> { public static Value evaluate(final Expression expr, final FormAnswers variables) { return expr.accept(new ExpressionEvaluator(variables)); } }
ExpressionEvaluator implements ExpressionVisitor<Value> { public static Value evaluate(final Expression expr, final FormAnswers variables) { return expr.accept(new ExpressionEvaluator(variables)); } private  ExpressionEvaluator(final FormAnswers variablesTable); }
ExpressionEvaluator implements ExpressionVisitor<Value> { public static Value evaluate(final Expression expr, final FormAnswers variables) { return expr.accept(new ExpressionEvaluator(variables)); } private  ExpressionEvaluator(final FormAnswers variablesTable); static Value evaluate(final Expression expr, final FormAnswers variables); @Override Value visit(final Addition expr); @Override Value visit(final Division expr); @Override Value visit(final Multiplication expr); @Override Value visit(final Subtraction expr); @Override Value visit(final Equal expr); @Override Value visit(final GreaterOrEqual expr); @Override Value visit(final GreaterThan expr); @Override Value visit(final LowerOrEqual expr); @Override Value visit(final LowerThan expr); @Override Value visit(final NotEqual expr); @Override Value visit(final And expr); @Override Value visit(final Or expr); @Override Value visit(final Not expr); @Override Value visit(final Identifier questionId); @Override BooleanValue visit(final BooleanLiteral expr); @Override StringValue visit(final StringLiteral expr); @Override NumberValue visit(final NumberLiteral expr); }
ExpressionEvaluator implements ExpressionVisitor<Value> { public static Value evaluate(final Expression expr, final FormAnswers variables) { return expr.accept(new ExpressionEvaluator(variables)); } private  ExpressionEvaluator(final FormAnswers variablesTable); static Value evaluate(final Expression expr, final FormAnswers variables); @Override Value visit(final Addition expr); @Override Value visit(final Division expr); @Override Value visit(final Multiplication expr); @Override Value visit(final Subtraction expr); @Override Value visit(final Equal expr); @Override Value visit(final GreaterOrEqual expr); @Override Value visit(final GreaterThan expr); @Override Value visit(final LowerOrEqual expr); @Override Value visit(final LowerThan expr); @Override Value visit(final NotEqual expr); @Override Value visit(final And expr); @Override Value visit(final Or expr); @Override Value visit(final Not expr); @Override Value visit(final Identifier questionId); @Override BooleanValue visit(final BooleanLiteral expr); @Override StringValue visit(final StringLiteral expr); @Override NumberValue visit(final NumberLiteral expr);  }