java.lang.Object
software.amazon.smithy.rulesengine.language.syntax.expressions.functions.FunctionNode
All Implemented Interfaces:
FromSourceLocation, ToNode, ToSmithyBuilder<FunctionNode>

public final class FunctionNode extends Object implements FromSourceLocation, ToNode, ToSmithyBuilder<FunctionNode>
Parsed but not validated function contents containing the `fn` name and `argv`.
  • Method Details

    • ofExpressions

      public static FunctionNode ofExpressions(String functionName, ToExpression... arguments)
      Constructs a FunctionNode for the given function name and arguments.
      Parameters:
      functionName - the function name.
      arguments - zero or more expressions as arguments to the function.
      Returns:
      the FunctionNode.
    • ofExpressions

      public static FunctionNode ofExpressions(String functionName, FromSourceLocation sourceLocation, ToExpression... arguments)
      Constructs a FunctionNode for the given function name and arguments.
      Parameters:
      functionName - the function name.
      sourceLocation - the source location for the function.
      arguments - zero or more expressions as arguments to the function.
      Returns:
      the FunctionNode.
    • builder

      public static FunctionNode.Builder builder()
      Returns a new builder instance.
      Returns:
      the new builder instance.
    • fromNode

      public static FunctionNode fromNode(ObjectNode function)
      Constructs a FunctionNode from the provided ObjectNode.
      Parameters:
      function - the node describing the function.
      Returns:
      the FunctionNode.
    • fromNode

      public static FunctionNode fromNode(ObjectNode function, EndpointComponentFactory factory)
      Constructs a FunctionNode from the provided ObjectNode, resolving argument functions using the given EndpointComponentFactory.

      When factory is null, the default statically-discovered function factory is used. Passing the factory ensures functions nested as arguments resolve against the same classloader as the enclosing rule-set.

      Parameters:
      function - the node describing the function.
      factory - the factory used to resolve argument functions, or null.
      Returns:
      the FunctionNode.
    • createFunction

      public LibraryFunction createFunction()
      Returns an expression representing this function.
      Returns:
      this function as an expression.
    • createFunction

      public LibraryFunction createFunction(EndpointComponentFactory factory)
      Returns an expression representing this function, resolving the function definition using the given EndpointComponentFactory.

      Use this overload when the function may be contributed by an endpoint extension that lives in a caller-supplied classloader. When factory is null, the function is resolved using the default, statically-discovered function factory.

      Parameters:
      factory - the factory used to resolve the function, or null to use the default.
      Returns:
      this function as an expression.
    • getName

      public String getName()
      Gets the name for the function described in this node.
      Returns:
      the name for the function.
    • getArguments

      public List<Expression> getArguments()
      Gets the list of argument Expressions to the function described in this node.
      Returns:
      the list of arguments.
    • getSourceLocation

      public SourceLocation getSourceLocation()
      Description copied from interface: FromSourceLocation
      Gets the source location of a value.
      Specified by:
      getSourceLocation in interface FromSourceLocation
      Returns:
      Returns the source location of the value.
    • toBuilder

      public FunctionNode.Builder toBuilder()
      Returns a new builder instance for this FunctionNode.
      Specified by:
      toBuilder in interface ToSmithyBuilder<FunctionNode>
      Returns:
      the new builder instance.
    • toNode

      public Node toNode()
      Description copied from interface: ToNode
      Converts a value to a Node.
      Specified by:
      toNode in interface ToNode
      Returns:
      Returns the creates Node.
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object