org.springframework.expression

Interface OperatorOverloader

  • All Known Implementing Classes:
    StandardOperatorOverloader


    public interface OperatorOverloader
    By default the mathematical operators Operation support simple types like numbers. By providing an implementation of OperatorOverloader, a user of the expression language can support these operations on other types.
    Since:
    3.0
    Author:
    Andy Clement
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method and Description
      java.lang.Object operate(Operation operation, java.lang.Object leftOperand, java.lang.Object rightOperand)
      Execute the specified operation on two operands, returning a result.
      boolean overridesOperation(Operation operation, java.lang.Object leftOperand, java.lang.Object rightOperand)
      Return true if the operator overloader supports the specified operation between the two operands and so should be invoked to handle it.
    • Method Detail

      • overridesOperation

        boolean overridesOperation(Operation operation,
                                   @Nullable
                                   java.lang.Object leftOperand,
                                   @Nullable
                                   java.lang.Object rightOperand)
                            throws EvaluationException
        Return true if the operator overloader supports the specified operation between the two operands and so should be invoked to handle it.
        Parameters:
        operation - the operation to be performed
        leftOperand - the left operand
        rightOperand - the right operand
        Returns:
        true if the OperatorOverloader supports the specified operation between the two operands
        Throws:
        EvaluationException - if there is a problem performing the operation
      • operate

        java.lang.Object operate(Operation operation,
                                 @Nullable
                                 java.lang.Object leftOperand,
                                 @Nullable
                                 java.lang.Object rightOperand)
                          throws EvaluationException
        Execute the specified operation on two operands, returning a result. See Operation for supported operations.
        Parameters:
        operation - the operation to be performed
        leftOperand - the left operand
        rightOperand - the right operand
        Returns:
        the result of performing the operation on the two operands
        Throws:
        EvaluationException - if there is a problem performing the operation