Record Class ListLiteralNode
java.lang.Object
java.lang.Record
cloud.opencode.base.expression.ast.ListLiteralNode
- Record Components:
elements- the list elements | 列表元素
- All Implemented Interfaces:
Node
List Literal Node
列表字面量节点
Represents a list literal like {1, 2, 3}.
表示列表字面量,如{1, 2, 3}。
Features | 主要功能:
- Inline list construction in expressions - 表达式中的内联列表构造
- Support nested expressions as elements - 支持嵌套表达式作为元素
- Empty list creation - 空列表创建
Usage Examples | 使用示例:
Node list = ListLiteralNode.of(
LiteralNode.ofInt(1),
LiteralNode.ofInt(2),
LiteralNode.ofInt(3)
);
List<?> result = (List<?>) list.evaluate(ctx); // [1, 2, 3]
Security | 安全性:
- Thread-safe: Yes, immutable record with defensive copy - 线程安全: 是,不可变记录,防御性拷贝
- Null-safe: No, null elements list rejected - 空值安全: 否,null元素列表被拒绝
- Since:
- JDK 25, opencode-base-expression V1.0.0
- Author:
- Leon Soo www.LeonSoo.com
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionListLiteralNode(List<Node> elements) Creates an instance of aListLiteralNoderecord class. -
Method Summary
Modifier and TypeMethodDescriptionelements()Returns the value of theelementsrecord component.static ListLiteralNodeempty()Create empty list literal node 创建空列表字面量节点final 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 ListLiteralNodeCreate list literal node from varargs 从可变参数创建列表字面量节点static ListLiteralNodeCreate list literal node 创建列表字面量节点Get string representation for debugging 获取用于调试的字符串表示final StringtoString()Returns a string representation of this record class.Methods inherited from interface Node
getTypeName
-
Constructor Details
-
ListLiteralNode
-
-
Method Details
-
of
Create list literal node 创建列表字面量节点- Parameters:
elements- the elements | 元素- Returns:
- the list node | 列表节点
-
of
Create list literal node from varargs 从可变参数创建列表字面量节点- Parameters:
elements- the elements | 元素- Returns:
- the list node | 列表节点
-
empty
Create empty list literal node 创建空列表字面量节点- Returns:
- the empty list 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). -
elements
-