Record Class PropertyAccessNode
java.lang.Object
java.lang.Record
cloud.opencode.base.expression.ast.PropertyAccessNode
- Record Components:
target- the target object node | 目标对象节点property- the property name | 属性名nullSafe- whether to use null-safe access | 是否使用空安全访问
- All Implemented Interfaces:
Node
public record PropertyAccessNode(Node target, String property, boolean nullSafe)
extends Record
implements Node
Property Access Node
属性访问节点
Represents property access: object.property, object?.property (null-safe)
表示属性访问:object.property, object?.property(空安全)
Features | 主要功能:
- JavaBean getter access (getXxx, isXxx) - JavaBean getter访问
- Record accessor method support - Record访问器方法支持
- Map key access - Map键访问
- Public field access - 公共字段访问
- Null-safe navigation (?.) - 空安全导航
- Custom PropertyAccessor SPI support - 自定义PropertyAccessor SPI支持
- Sandbox-controlled property access - 沙箱控制的属性访问
Usage Examples | 使用示例:
// user.name
Node prop = PropertyAccessNode.of(userNode, "name");
Object name = prop.evaluate(ctx);
// user?.address - null-safe
Node safe = PropertyAccessNode.nullSafe(userNode, "address");
Security | 安全性:
- Thread-safe: Yes, immutable record - 线程安全: 是,不可变记录
- Null-safe: Optional via nullSafe mode - 空值安全: 通过nullSafe模式可选
- Only public fields and methods accessible - 仅可访问公共字段和方法
- Since:
- JDK 25, opencode-base-expression V1.0.0
- Author:
- Leon Soo www.LeonSoo.com
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionPropertyAccessNode(Node target, String property, boolean nullSafe) Creates an instance of aPropertyAccessNoderecord class. -
Method Summary
Modifier and TypeMethodDescriptionfinal booleanIndicates whether some other object is "equal to" this one.evaluate(EvaluationContext context) Evaluate this node 求值此节点static ObjectgetPropertyValue(Object target, String property, EvaluationContext context) Get property value from object 从对象获取属性值final inthashCode()Returns a hash code value for this object.booleannullSafe()Returns the value of thenullSaferecord component.static PropertyAccessNodeCreate null-safe property access 创建空安全属性访问static PropertyAccessNodeCreate standard property access 创建标准属性访问static PropertyAccessNodeCreate property access with null-safe option 创建带空安全选项的属性访问property()Returns the value of thepropertyrecord component.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
-
Method Details
-
of
Create standard property access 创建标准属性访问- Parameters:
target- the target node | 目标节点property- the property name | 属性名- Returns:
- the property access node | 属性访问节点
-
nullSafe
Create null-safe property access 创建空安全属性访问- Parameters:
target- the target node | 目标节点property- the property name | 属性名- Returns:
- the null-safe property access node | 空安全属性访问节点
-
of
Create property access with null-safe option 创建带空安全选项的属性访问- Parameters:
target- the target node | 目标节点property- the property name | 属性名nullSafe- whether to use null-safe access | 是否使用空安全访问- Returns:
- the property access node | 属性访问节点
-
evaluate
Description copied from interface:NodeEvaluate this node 求值此节点 -
getPropertyValue
Get property value from object 从对象获取属性值- Parameters:
target- the target object | 目标对象property- the property name | 属性名context- the evaluation context | 求值上下文- Returns:
- the property value | 属性值
-
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
-
property
-
nullSafe
-