Record Class BitwiseOpNode
java.lang.Object
java.lang.Record
cloud.opencode.base.expression.ast.BitwiseOpNode
- Record Components:
operator- the bitwise operator | 位运算符left- the left operand (or sole operand for ~) | 左操作数(~ 运算的唯一操作数)right- the right operand (null for ~) | 右操作数(~ 运算时为 null)
- All Implemented Interfaces:
Node
Bitwise Operation Node
位运算节点
Represents bitwise operations: AND, OR, XOR, NOT, left shift, right shift.
表示位运算:与、或、异或、取反、左移、右移。
Features | 主要功能:
- Binary bitwise:
&,|,^,<<,>>- 二元位运算 - Unary bitwise NOT:
~- 一元位取反 - Operands converted to long for computation - 操作数转换为 long 进行计算
Usage Examples | 使用示例:
// 0xFF & 0x0F
Node and = BitwiseOpNode.of(leftNode, "&", rightNode);
Object result = and.evaluate(ctx); // 15L
// ~value
Node not = BitwiseOpNode.ofNot(operandNode);
Object result2 = not.evaluate(ctx);
Security | 安全性:
- Thread-safe: Yes, immutable record - 线程安全: 是,不可变记录
- Null-safe: No, operator and left required non-null; right nullable only for ~ - 空值安全: 否,运算符和左操作数要求非空;右操作数仅在 ~ 时可为空
- Type-safe: Throws exception for non-integer types - 类型安全:非整数类型抛出异常
- Since:
- JDK 25, opencode-base-expression V1.0.3
- Author:
- Leon Soo www.LeonSoo.com
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionBitwiseOpNode(String operator, Node left, Node right) Creates an instance of aBitwiseOpNoderecord class. -
Method Summary
Modifier and TypeMethodDescriptionfinal booleanIndicates whether some other object is "equal to" this one.evaluate(EvaluationContext context) Evaluate this node 求值此节点final inthashCode()Returns a hash code value for this object.left()Returns the value of theleftrecord component.static BitwiseOpNodeCreate binary bitwise operation node 创建二元位运算节点static BitwiseOpNodeCreate unary bitwise NOT node 创建一元位取反节点operator()Returns the value of theoperatorrecord component.right()Returns the value of therightrecord component.Get string representation for debugging 获取用于调试的字符串表示final StringtoString()Returns a string representation of this record class.Methods inherited from interface Node
getTypeName
-
Constructor Details
-
BitwiseOpNode
-
-
Method Details
-
of
Create binary bitwise operation node 创建二元位运算节点- Parameters:
left- the left operand | 左操作数operator- the operator string (&,|,^,<<,>>) | 运算符字符串right- the right operand | 右操作数- Returns:
- the bitwise operation node | 位运算节点
-
ofNot
Create unary bitwise NOT node 创建一元位取反节点- Parameters:
operand- the operand | 操作数- Returns:
- the bitwise NOT node | 位取反节点
-
evaluate
Description copied from interface:NodeEvaluate this node 求值此节点 -
toExpressionString
Description copied from interface:NodeGet string representation for debugging 获取用于调试的字符串表示- Specified by:
toExpressionStringin interfaceNode- Returns:
- the string representation | 字符串表示
-
toString
-
hashCode
-
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared withObjects::equals(Object,Object). -
operator
-
left
-
right
-