Interface IJavaOperator
This interface is used to define a Java operator.
-
Method Summary
Modifier and TypeMethodDescriptionbooleanDetermine whether evaluating this operator may cause an exception.voidformat(DFormattingContext fctx) Format this operator.Get the associativity (left, right) of the operator.Return the cast type of a cast operator.Retrieve the operator factory that created this operator.Retrieve the mirrored operator.Get the type of operator represented by this object.intGet the precedence of the operator.intgetPrecedenceDelta(IJavaOperator other) Check the precedence of this operator against another operator.Retrieve the logical reverse operator.default JavaOperatorTypegetType()Get the type of operator represented by this object.booleanis(JavaOperatorType optype) Determine whether this operator has a specific type.booleanisAnyOf(JavaOperatorType... optypes) Determine whether this operator has any of the provided types.booleanDetermine if the operator is an arithmetic or bitwise operator.booleanisBinary()Determine if the operator uses two operands.booleanisCast()Determine if the operator is a cast operator.booleanDetermine if the operator is a cast operator to a primitive type.booleanDetermine if the operator is a logical operator, i.e.booleanisNoneOf(JavaOperatorType... optypes) Determine whether this operator has none of the provided types.booleanisUnary()Determine if the operator uses a single operand.booleanDetermine if this operator is one of the 11 (+1) arithmetic operators that can be used to build a combined-operator assignment.
-
Method Details
-
getFactory
IJavaOperatorFactory getFactory()Retrieve the operator factory that created this operator.- Returns:
- operator factory
-
is
Determine whether this operator has a specific type.- Parameters:
optype- operator type- Returns:
- true if this operator has the provided type
-
isAnyOf
Determine whether this operator has any of the provided types.- Parameters:
optypes- operator types- Returns:
- true if this operator has one of the provided types
-
isNoneOf
Determine whether this operator has none of the provided types.- Parameters:
optypes- operator types- Returns:
- true if this operator has none of the provided types
-
getOperatorType
JavaOperatorType getOperatorType()Get the type of operator represented by this object.- Returns:
- operator type
-
getType
Get the type of operator represented by this object.- Returns:
- operator type
-
isUnary
boolean isUnary()Determine if the operator uses a single operand.- Returns:
- true if the operator is a unary operator
-
isBinary
boolean isBinary()Determine if the operator uses two operands.- Returns:
- true if the operator is a binary operator
-
isArithmetic
boolean isArithmetic()Determine if the operator is an arithmetic or bitwise operator.- Returns:
- true for
ADD, SUB, MUL, DIV, REM, AND, OR, XOR, SHL, SHR, USHR, NEG, NOT
-
isLogical
boolean isLogical()Determine if the operator is a logical operator, i.e. one that evaluates to true or false.- Returns:
- true for
LOG_IDENT, LOG_NOT, LOG_OR, LOG_AND, EQ, NE, LT, GE, GT, LE, INSTANCEOF
-
isCast
boolean isCast()Determine if the operator is a cast operator.- Returns:
- true if the operator is a cast operator
-
isCastToPrimitive
boolean isCastToPrimitive()Determine if the operator is a cast operator to a primitive type.- Returns:
- true if the operator casts to a primitive type
-
getCastType
IJavaType getCastType()Return the cast type of a cast operator. This method will throw if the operator is not a cast operator. UseisCast()first.- Returns:
- the cast-to object type
-
isValidForCombinedAssignment
boolean isValidForCombinedAssignment()Determine if this operator is one of the 11 (+1) arithmetic operators that can be used to build a combined-operator assignment.- Returns:
- true if one of: mul, div, add, sub, rem, shl, shr, ushr, and, xor, or
-
getPrecedenceDelta
Check the precedence of this operator against another operator.- Parameters:
other- operator to compare with this one- Returns:
- delta: negative if this operator has higher precedence than other, 0 if their precedence is the same, or positive if this operator has lower precedence than other
- Throws:
Exception- if precedence cannot be determined
-
getPrecedence
int getPrecedence()Get the precedence of the operator. Currently not implemented for all operators, and the method will throw if it cannot find a precedence value.- Returns:
- operator precedence
- Throws:
RuntimeException- if the precedence is not found
-
getAssociativity
JavaOperatorType.Associativity getAssociativity()Get the associativity (left, right) of the operator.- Returns:
- operator associativity
- Throws:
RuntimeException- if the associativity is not found
-
canCauseException
boolean canCauseException()Determine whether evaluating this operator may cause an exception.- Returns:
- true if the operator may cause an exception
-
format
Format this operator.- Parameters:
fctx- formatting context
-
getReverse
IJavaOperator getReverse()Retrieve the logical reverse operator.- Returns:
- reverse operator, or null if none exists
-
getMirror
IJavaOperator getMirror()Retrieve the mirrored operator.- Returns:
- mirror operator, or null if none exists
-