Class Snippet

java.lang.Object
org.graalvm.polyglot.tck.Snippet

public final class Snippet extends Object
The unit of execution with assigned parameters and result types. The Snippet represents an execution of value constructor, statement, expression and script. The Snippet provides parameter(s) and return types used to compose the Snippets.
Since:
0.30
  • Method Details

    • getId

      public String getId()
      Returns the identifier of a snippet. The Snippets from a single LanguageProvider with the same identifier but different types are treated as overloads.
      Returns:
      the Snippet identifier
      Since:
      0.30
    • getExecutableValue

      public org.graalvm.polyglot.Value getExecutableValue()
      Returns the function executing the Snippet.
      Returns:
      the executable Value
      Since:
      0.30
    • getReturnType

      public TypeDescriptor getReturnType()
      Returns the Snippet return type.
      Returns:
      the return type
      Since:
      0.30
    • getParameterTypes

      public List<? extends TypeDescriptor> getParameterTypes()
      Returns the types of Snippet formal parameters.
      Returns:
      the parameter types
      Since:
      0.30
    • getResultVerifier

      public ResultVerifier getResultVerifier()
      Returns the ResultVerifier to verify the execution result.
      Returns:
      either a custom or the default ResultVerifier.
      Since:
      0.30
    • toString

      public String toString()
      Overrides:
      toString in class Object
      Since:
      0.30
    • newBuilder

      public static Snippet.Builder newBuilder(String id, org.graalvm.polyglot.Value executableValue, TypeDescriptor executableReturnType)
      Creates a new Snippet builder object.
      Parameters:
      id - the Snippet identifier The Snippets from a single LanguageProvider with the same identifier but different types are treated as overloads.
      executableValue - the executable Value used to execute the Snippet
      executableReturnType - the Snippet return type
      Returns:
      the new Snippet.Builder
      Since:
      0.30