Record Class UnaryOpNode
java.lang.Object
java.lang.Record
cloud.opencode.base.expression.ast.UnaryOpNode
- Record Components:
operator- the operator (-, !) | 运算符operand- the operand | 操作数
- All Implemented Interfaces:
Node
Unary Operation Node
一元运算节点
Represents unary operations: negation, logical not.
表示一元运算:取负、逻辑非。
Features | 主要功能:
- Numeric negation (-) - 数值取负
- Logical not (!) - 逻辑非
- Unary plus (+) no-op - 一元加号(无操作)
Usage Examples | 使用示例:
Node neg = UnaryOpNode.of("-", LiteralNode.ofInt(5));
Object result = neg.evaluate(ctx); // -5
Node not = UnaryOpNode.of("!", LiteralNode.ofBoolean(true));
Object result2 = not.evaluate(ctx); // false
Security | 安全性:
- Thread-safe: Yes, immutable record - 线程安全: 是,不可变记录
- Null-safe: No, operator and operand required non-null - 空值安全: 否,运算符和操作数要求非空
- Since:
- JDK 25, opencode-base-expression V1.0.0
- Author:
- Leon Soo www.LeonSoo.com
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionUnaryOpNode(String operator, Node operand) Creates an instance of aUnaryOpNoderecord 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.static UnaryOpNodeCreate unary operation node 创建一元运算节点operand()Returns the value of theoperandrecord component.operator()Returns the value of theoperatorrecord component.Get string representation for debugging 获取用于调试的字符串表示final StringtoString()Returns a string representation of this record class.Methods inherited from interface Node
getTypeName
-
Constructor Details
-
UnaryOpNode
-
-
Method Details
-
of
Create unary operation node 创建一元运算节点- Parameters:
operator- the operator string | 运算符字符串operand- the operand | 操作数- Returns:
- the unary operation 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
-
operand
-