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()
    • checkOperatorType

      default boolean checkOperatorType(JavaOperatorType optype)
    • getCountOfOperands

      int getCountOfOperands()
    • getLeft

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

      void setLeft(IJavaExpression left)
    • getRight

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

      void setRight(IJavaExpression right)
    • canReverse

      boolean canReverse()
    • reverse

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

      boolean canMirror()
    • mirror

      boolean mirror(IJavaOperatorFactory of)
      Mirror the operation order, whenever possible. The object is modified.
      Parameters:
      of -
      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