public class BinaryOperation extends Operation<BinaryOperator>
Constructor and Description |
---|
BinaryOperation(Expression leftOperand,
BinaryOperator operator,
Expression rightOperand)
Creates a new binary operation.
|
Modifier and Type | Method and Description |
---|---|
Object |
accept(ExpressionVisitor visitor)
Accepts to visit the given expression visitor.
|
Value |
evaluate()
Evaluates the expression and returns the result.
|
Expression |
getLeftOperand()
Returns the left(first) operand.
|
Expression |
getRightOperand()
Returns the right(second) operand.
|
String |
toString() |
getOperator
public BinaryOperation(Expression leftOperand, BinaryOperator operator, Expression rightOperand)
leftOperand
- the left(first) operandoperator
- the binary operatorrightOperand
- the right(second) operandpublic Value evaluate() throws IllegalValueTypeException
Expression
IllegalValueTypeException
- if a value of an unexpected type was
encountered when evaluating the expressionpublic Expression getLeftOperand()
public Expression getRightOperand()
public Object accept(ExpressionVisitor visitor)
Expression
visitor
- the visitor