Enum Class BinaryOp
- All Implemented Interfaces:
Serializable
,Comparable<BinaryOp>
,Constable
Represents the operator of an infix expression.
Constants are roughly ordered by precedence, except some of them have the same
precedence.
All of those operators are left-associative.
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Enum
Enum.EnumDesc<E extends Enum<E>>
-
Enum Constant Summary
Enum ConstantsEnum ConstantDescriptionAddition"+"
operator, or string concatenation.AND"&"
operator.Conditional (shortcut) AND"&&"
operator.Conditional (shortcut) OR"||"
operator.Division"/"
operator.Equals"=="
operator.Greater-or-equal">="
operator.Greater-than">"
operator.Type test"instanceof"
operator.Lower-or-equal"<="
operator.Left shift"<<"
operator.Lower-than"<"
operator.Modulo"%"
operator.Multiplication"*"
operator.Not-equals"!="
operator.OR"|"
operator.Right shift">>"
operator.Subtraction"-"
operator.Unsigned right shift">>>"
operator.XOR"^"
operator. -
Field Summary
FieldsModifier and TypeFieldDescriptionSet of<
,<=
,>=
and>
.Set of&&
and||
.Set of==
and!=
.Set of<<
,>>
and>>>
. -
Method Summary
Modifier and TypeMethodDescriptionint
comparePrecedence
(@NonNull BinaryOp other) Compare the precedence of this operator with that of the other, as if with aComparator
.@Nullable BinaryOp
Complement, for boolean operators.getToken()
boolean
hasSamePrecedenceAs
(@NonNull BinaryOp other) Returns true if this operator has the same relative precedence as the argument.Returns the ops with strictly greater precedence than the given op.toString()
static BinaryOp
Returns the enum constant of this class with the specified name.static BinaryOp[]
values()
Returns an array containing the constants of this enum class, in the order they are declared.
-
Enum Constant Details
-
CONDITIONAL_OR
Conditional (shortcut) OR"||"
operator. -
CONDITIONAL_AND
Conditional (shortcut) AND"&&"
operator. -
OR
OR"|"
operator. Either logical or bitwise depending on the type of the operands. -
XOR
XOR"^"
operator. Either logical or bitwise depending on the type of the operands. -
AND
AND"&"
operator. Either logical or bitwise depending on the type of the operands. -
EQ
Equals"=="
operator. -
NE
Not-equals"!="
operator. -
LE
Lower-or-equal"<="
operator. -
GE
Greater-or-equal">="
operator. -
GT
Greater-than">"
operator. -
LT
Lower-than"<"
operator. -
INSTANCEOF
Type test"instanceof"
operator. -
LEFT_SHIFT
Left shift"<<"
operator. -
RIGHT_SHIFT
Right shift">>"
operator. -
UNSIGNED_RIGHT_SHIFT
Unsigned right shift">>>"
operator. -
ADD
Addition"+"
operator, or string concatenation. -
SUB
Subtraction"-"
operator. -
MUL
Multiplication"*"
operator. -
DIV
Division"/"
operator. -
MOD
Modulo"%"
operator.
-
-
Field Details
-
CONDITIONAL_OPS
Set of&&
and||
. Use withJavaAstUtils.isInfixExprWithOperator(JavaNode, Set)
. -
COMPARISON_OPS
Set of<
,<=
,>=
and>
. Use withJavaAstUtils.isInfixExprWithOperator(JavaNode, Set)
. -
EQUALITY_OPS
Set of==
and!=
. Use withJavaAstUtils.isInfixExprWithOperator(JavaNode, Set)
. -
SHIFT_OPS
Set of<<
,>>
and>>>
. Use withJavaAstUtils.isInfixExprWithOperator(JavaNode, Set)
.
-
-
Method Details
-
values
Returns an array containing the constants of this enum class, in the order they are declared.- Returns:
- an array containing the constants of this enum class, in the order they are declared
-
valueOf
Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)- Parameters:
name
- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
IllegalArgumentException
- if this enum class has no constant with the specified nameNullPointerException
- if the argument is null
-
getToken
-
toString
-
comparePrecedence
Compare the precedence of this operator with that of the other, as if with aComparator
. Returns a positive integer if this operator has a higher precedence as the argument, zero if they have the same precedence, etc.- Throws:
NullPointerException
- If the argument is null
-
hasSamePrecedenceAs
Returns true if this operator has the same relative precedence as the argument. For example,ADD
andSUB
have the same precedence.- Throws:
NullPointerException
- If the argument is null
-
opsWithGreaterPrecedence
Returns the ops with strictly greater precedence than the given op. This may return an empty set. -
getComplement
Complement, for boolean operators. Eg for==
, return!=
, for<=
, returns>
. Returns null if this is another kind of operator.
-