Class ExpressionNode.BinaryExpressionNode

  • Enclosing class:
    ExpressionNode

    static class ExpressionNode.BinaryExpressionNode
    extends ExpressionNode
    Represents all binary expressions. In #set ($a = $b + $c), this will be the type of the node representing $b + $c.
    • Method Detail

      • evaluate

        java.lang.Object evaluate​(EvaluationContext context)
        Description copied from class: Node
        Returns the result of evaluating this node in the given context. This result may be used as part of a further operation, for example evaluating 2 + 3 to 5 in order to set $x to 5 in #set ($x = 2 + 3). Or it may be used directly as part of the template output, for example evaluating replacing name by Fred in My name is $name..
        Specified by:
        evaluate in class Node
      • equal

        private boolean equal​(EvaluationContext context)
        Returns true if lhs and rhs are equal according to Velocity.

        Velocity's definition of equality differs depending on whether the objects being compared are of the same class. If so, equality comes from Object.equals as you would expect. But if they are not of the same class, they are considered equal if their toString() values are equal. This means that integer 123 equals long 123L and also string "123". It also means that equality isn't always transitive. For example, two StringBuilder objects each containing "123" will not compare equal, even though the string "123" compares equal to each of them.