Class Operator

java.lang.Object
org.springframework.expression.spel.ast.SpelNodeImpl
org.springframework.expression.spel.ast.Operator
All Implemented Interfaces:
Opcodes, SpelNode
Direct Known Subclasses:
OpAnd, OpDec, OpDivide, OpEQ, OperatorBetween, OperatorInstanceof, OperatorMatches, OperatorPower, OpGE, OpGT, OpInc, OpLE, OpLT, OpMinus, OpModulus, OpMultiply, OpNE, OpOr, OpPlus

public abstract class Operator extends SpelNodeImpl
Common supertype for operators that operate on either one or two operands. In the case of multiply or divide there would be two operands, but for unary plus or minus, there is only one.
Since:
3.0
Author:
Andy Clement, Juergen Hoeller, Giovanni Dall'Oglio Risso, Sam Brannen
  • Field Details

  • Constructor Details

    • Operator

      public Operator(String payload, int startPos, int endPos, SpelNodeImpl... operands)
  • Method Details

    • getLeftOperand

      public SpelNodeImpl getLeftOperand()
    • getRightOperand

      public SpelNodeImpl getRightOperand()
    • getOperatorName

      public final String getOperatorName()
    • toStringAST

      public String toStringAST()
      String format for all operators is the same '(' [operand] [operator] [operand] ')'.
      Returns:
      the string form
    • isCompilableOperatorUsingNumerics

      protected boolean isCompilableOperatorUsingNumerics()
    • generateComparisonCode

      protected void generateComparisonCode(MethodVisitor mv, CodeFlow cf, int compInstruction1, int compInstruction2)
      Numeric comparison operators share very similar generated code, only differing in two comparison instructions.
    • equalityCheck

      public static boolean equalityCheck(EvaluationContext context, @Nullable Object left, @Nullable Object right)
      Perform an equality check for the given operand values.

      This method is not just used for reflective comparisons in subclasses but also from compiled expression code, which is why it needs to be declared as public static here.

      Parameters:
      context - the current evaluation context
      left - the left-hand operand value
      right - the right-hand operand value