Record Class IndexAccessNode
java.lang.Object
java.lang.Record
cloud.opencode.base.expression.ast.IndexAccessNode
- Record Components:
target- the target object node | 目标对象节点index- the index expression | 索引表达式nullSafe- whether to use null-safe access | 是否使用空安全访问
- All Implemented Interfaces:
Node
public record IndexAccessNode(Node target, Node index, boolean nullSafe)
extends Record
implements Node
Index Access Node
索引访问节点
Represents index access: list[0], array[i], map["key"]
表示索引访问:list[0], array[i], map["key"]
Features | 主要功能:
- List and array index access - 列表和数组索引访问
- Map key access - Map键访问
- String charAt access - 字符串字符访问
- Null-safe access mode (?[]) - 空安全访问模式
Usage Examples | 使用示例:
Node list = IdentifierNode.of("items");
Node index = LiteralNode.ofInt(0);
Node access = IndexAccessNode.of(list, index);
Object first = access.evaluate(ctx);
// Null-safe access
Node safe = IndexAccessNode.nullSafe(list, index);
Security | 安全性:
- Thread-safe: Yes, immutable record - 线程安全: 是,不可变记录
- Null-safe: Optional via nullSafe mode - 空值安全: 通过nullSafe模式可选
- Since:
- JDK 25, opencode-base-expression V1.0.0
- Author:
- Leon Soo www.LeonSoo.com
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionIndexAccessNode(Node target, Node index, boolean nullSafe) Creates an instance of aIndexAccessNoderecord 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.index()Returns the value of theindexrecord component.booleannullSafe()Returns the value of thenullSaferecord component.static IndexAccessNodeCreate null-safe index access 创建空安全索引访问static IndexAccessNodeCreate standard index access 创建标准索引访问target()Returns the value of thetargetrecord component.Get string representation for debugging 获取用于调试的字符串表示final StringtoString()Returns a string representation of this record class.Methods inherited from interface Node
getTypeName
-
Constructor Details
-
IndexAccessNode
-
-
Method Details
-
of
Create standard index access 创建标准索引访问- Parameters:
target- the target node | 目标节点index- the index node | 索引节点- Returns:
- the index access node | 索引访问节点
-
nullSafe
Create null-safe index access 创建空安全索引访问- Parameters:
target- the target node | 目标节点index- the index node | 索引节点- Returns:
- the null-safe index access 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. Reference components are compared withObjects::equals(Object,Object); primitive components are compared with thecomparemethod from their corresponding wrapper classes. -
target
-
index
-
nullSafe
-