Record Class FunctionCallNode

java.lang.Object
java.lang.Record
cloud.opencode.base.expression.ast.FunctionCallNode
Record Components:
functionName - the function name | 函数名
arguments - the function arguments | 函数参数
All Implemented Interfaces:
Node

public record FunctionCallNode(String functionName, List<Node> arguments) extends Record implements Node
Function Call Node 函数调用节点

Represents function calls: upper(str), max(a, b)

表示函数调用:upper(str), max(a, b)

Features | 主要功能:

  • Invoke registered functions by name - 按名称调用已注册的函数
  • Support variable number of arguments - 支持可变数量参数
  • Function lookup via context's FunctionRegistry - 通过上下文的FunctionRegistry查找函数

Usage Examples | 使用示例:

Node arg = LiteralNode.ofString("hello");
Node call = FunctionCallNode.of("upper", arg);
Object result = call.evaluate(ctx);  // "HELLO"

Security | 安全性:

  • Thread-safe: Yes, immutable record with defensive copy of arguments - 线程安全: 是,不可变记录,参数进行防御性拷贝
  • Null-safe: No, function name required non-null - 空值安全: 否,函数名要求非空
Since:
JDK 25, opencode-base-expression V1.0.0
Author:
Leon Soo www.LeonSoo.com
See Also:
  • Constructor Details

    • FunctionCallNode

      public FunctionCallNode(String functionName, List<Node> arguments)
      Creates an instance of a FunctionCallNode record class.
      Parameters:
      functionName - the value for the functionName record component
      arguments - the value for the arguments record component
  • Method Details

    • of

      public static FunctionCallNode of(String functionName, List<Node> arguments)
      Create function call node 创建函数调用节点
      Parameters:
      functionName - the function name | 函数名
      arguments - the arguments | 参数
      Returns:
      the function call node | 函数调用节点
    • of

      public static FunctionCallNode of(String functionName, Node argument)
      Create function call node with single argument 创建单参数函数调用节点
      Parameters:
      functionName - the function name | 函数名
      argument - the argument | 参数
      Returns:
      the function call node | 函数调用节点
    • evaluate

      public Object evaluate(EvaluationContext context)
      Description copied from interface: Node
      Evaluate this node 求值此节点
      Specified by:
      evaluate in interface Node
      Parameters:
      context - the evaluation context | 求值上下文
      Returns:
      the evaluation result | 求值结果
    • toExpressionString

      public String toExpressionString()
      Description copied from interface: Node
      Get string representation for debugging 获取用于调试的字符串表示
      Specified by:
      toExpressionString in interface Node
      Returns:
      the string representation | 字符串表示
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      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 with Objects::equals(Object,Object).
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • functionName

      public String functionName()
      Returns the value of the functionName record component.
      Returns:
      the value of the functionName record component
    • arguments

      public List<Node> arguments()
      Returns the value of the arguments record component.
      Returns:
      the value of the arguments record component