Record Class MethodCallNode
java.lang.Object
java.lang.Record
cloud.opencode.base.expression.ast.MethodCallNode
- Record Components:
target- the target object node | 目标对象节点methodName- the method name | 方法名arguments- the method arguments | 方法参数nullSafe- whether to use null-safe access | 是否使用空安全访问
- All Implemented Interfaces:
Node
public record MethodCallNode(Node target, String methodName, List<Node> arguments, boolean nullSafe)
extends Record
implements Node
Method Call Node
方法调用节点
Represents method calls: str.toUpperCase(), list.size()
表示方法调用:str.toUpperCase(), list.size()
Features | 主要功能:
- Reflective method invocation on target objects - 对目标对象的反射方法调用
- Null-safe method call (?.) support - 空安全方法调用(?.)支持
- Varargs method support - 可变参数方法支持
- Sandbox-controlled method access - 沙箱控制的方法访问
- Primitive type auto-boxing - 原始类型自动装箱
Usage Examples | 使用示例:
// str.toUpperCase()
Node call = MethodCallNode.of(strNode, "toUpperCase", List.of());
Object result = call.evaluate(ctx);
// obj?.method() - null-safe
Node safe = MethodCallNode.nullSafe(objNode, "method", List.of());
Security | 安全性:
- Thread-safe: Yes, immutable record - 线程安全: 是,不可变记录
- Null-safe: Optional via nullSafe mode - 空值安全: 通过nullSafe模式可选
- Sandbox enforcement on method calls - 方法调用的沙箱强制执行
- Only public methods accessible - 仅可访问公共方法
- Since:
- JDK 25, opencode-base-expression V1.0.0
- Author:
- Leon Soo www.LeonSoo.com
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionMethodCallNode(Node target, String methodName, List<Node> arguments, boolean nullSafe) Creates an instance of aMethodCallNoderecord class. -
Method Summary
Modifier and TypeMethodDescriptionReturns the value of theargumentsrecord component.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.Returns the value of themethodNamerecord component.booleannullSafe()Returns the value of thenullSaferecord component.static MethodCallNodeCreate null-safe method call node 创建空安全方法调用节点static MethodCallNodeCreate method call node 创建方法调用节点static MethodCallNodeCreate method call node with null-safe option 创建带空安全选项的方法调用节点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
-
MethodCallNode
Creates an instance of aMethodCallNoderecord class.- Parameters:
target- the value for thetargetrecord componentmethodName- the value for themethodNamerecord componentarguments- the value for theargumentsrecord componentnullSafe- the value for thenullSaferecord component
-
-
Method Details
-
of
Create method call node 创建方法调用节点- Parameters:
target- the target node | 目标节点methodName- the method name | 方法名arguments- the arguments | 参数- Returns:
- the method call node | 方法调用节点
-
nullSafe
Create null-safe method call node 创建空安全方法调用节点- Parameters:
target- the target node | 目标节点methodName- the method name | 方法名arguments- the arguments | 参数- Returns:
- the null-safe method call node | 空安全方法调用节点
-
of
public static MethodCallNode of(Node target, String methodName, List<Node> arguments, boolean nullSafe) Create method call node with null-safe option 创建带空安全选项的方法调用节点- Parameters:
target- the target node | 目标节点methodName- the method name | 方法名arguments- the arguments | 参数nullSafe- whether to use null-safe access | 是否使用空安全访问- Returns:
- the method call 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
-
methodName
Returns the value of themethodNamerecord component.- Returns:
- the value of the
methodNamerecord component
-
arguments
-
nullSafe
-