Interface IJavaOperation

All Superinterfaces:
IJavaElement, IJavaExpression
All Known Subinterfaces:
IJavaPredicate_LEGACY

@Ser public interface IJavaOperation extends IJavaExpression
Java AST interface to represent arithmetic and logical expressions.

An expression consists of one or two members (the left and right members) and an operator. The left member is optional, and should be null for unary operators.

Examples:

 a + 1
 a * ((int)b - foo())
 !x
 x ^ y | z
 
  • Method Details

    • getOperator

      IJavaOperator getOperator()
      Get the expression's operator.
      Returns:
      the operator
    • setOperator

      void setOperator(IJavaOperator operator)
      Set the operator for the expression. Dangerous method! the operator type is not checked, it is the caller's responsibility to do so.
      Parameters:
      operator - operator, cannot be null
    • getOperatorType

      default JavaOperatorType getOperatorType()
      Retrieve the operation's operator type.
      Returns:
      operator type
    • checkOperatorType

      default boolean checkOperatorType(JavaOperatorType optype)
      Determine whether this operation uses a specific operator type.
      Parameters:
      optype - operator type
      Returns:
      true if this operation uses the provided operator type
    • getCountOfOperands

      int getCountOfOperands()
      Retrieve the operand count.
      Returns:
      operand count
    • getLeft

      IJavaExpression getLeft()
      Get the left member sub-expression.
      Returns:
      the left expression, null if none
    • setLeft

      void setLeft(IJavaExpression left)
      Set the left member sub-expression.
      Parameters:
      left - left expression, or null for unary operators
    • getRight

      IJavaExpression getRight()
      Get the right sub-expression.
      Returns:
      the right expression
    • setRight

      void setRight(IJavaExpression right)
      Set the right member sub-expression.
      Parameters:
      right - right expression
    • canReverse

      boolean canReverse()
      Determine whether this operation can be logically reversed.
      Returns:
      true if reverse(IJavaOperatorFactory) may succeed
    • reverse

      boolean reverse(IJavaOperatorFactory of)
      Logical negation of the operation, whenever possible. The object is modified.
      Parameters:
      of - operator factory
      Returns:
      true if reversing was possible, false otherwise
    • canMirror

      boolean canMirror()
      Determine whether this operation can be mirrored.
      Returns:
      true if mirror(IJavaOperatorFactory) may succeed
    • mirror

      boolean mirror(IJavaOperatorFactory of)
      Mirror the operation order, whenever possible. The object is modified.
      Parameters:
      of - operator factory
      Returns:
      true if mirroring was possible, false otherwise
    • duplicate

      IJavaOperation duplicate()
      Description copied from interface: IJavaElement
      Duplicate this element.
      Specified by:
      duplicate in interface IJavaElement
      Specified by:
      duplicate in interface IJavaExpression
      Returns:
      a (possibly) duplicated object of the same type