Top Description Inners Fields Constructors Methods
org.graalvm.polyglot.tck

public final Class Snippet

extends Object
Class Inheritance
Imports
java.util.ArrayList, .Arrays, .Collections, .List, .Objects, java.util.stream.Collectors, org.graalvm.polyglot.Value

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

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class
Snippet.Builder

The builder of a Snippet.

Field Summary

Modifier and TypeField and Description
private final Value
private final String
private final List<? extends TypeDescriptor>
private final TypeDescriptor
private final ResultVerifier

Constructor Summary

AccessConstructor and Description
private
Snippet(final String id, final Value executableValue, final TypeDescriptor type, final List<? extends TypeDescriptor> parameterTypes, final ResultVerifier verifier)

Method Summary

Modifier and TypeMethod and Description
public Value

Returns:

the executable Value
getExecutableValue
()

Returns the function executing the Snippet.

public String

Returns:

the Snippet identifier
getId
()

Returns the identifier of a snippet.

public List<? extends TypeDescriptor>

Returns:

the parameter types
getParameterTypes
()

Returns the types of Snippet formal parameters.

public ResultVerifier

Returns:

either a custom or the default ResultVerifier.
getResultVerifier
()

Returns the ResultVerifier to verify the execution result.

public TypeDescriptor

Returns:

the return type
getReturnType
()

Returns the Snippet return type.

public static Snippet.Builder

Returns:

the new Builder
newBuilder
(final String
the Snippet identifier The Snippets from a single LanguageProvider with the same identifier but different types are treated as overloads.
id
,
final Value
the executable Value used to execute the Snippet
executableValue
,
final TypeDescriptor
the Snippet return type
executableReturnType
)

Creates a new Snippet builder object.

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

executableValueback to summary
private final Value executableValue
idback to summary
private final String id
parameterTypesback to summary
private final List<? extends TypeDescriptor> parameterTypes
typeback to summary
private final TypeDescriptor type
verifierback to summary
private final ResultVerifier verifier

Constructor Detail

Snippetback to summary
private Snippet(final String id, final Value executableValue, final TypeDescriptor type, final List<? extends TypeDescriptor> parameterTypes, final ResultVerifier verifier)

Method Detail

getExecutableValueback to summary
public Value getExecutableValue()

Returns the function executing the Snippet.

Returns:Value

the executable Value

Since
0.30
getIdback to summary
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:String

the Snippet identifier

Since
0.30
getParameterTypesback to summary
public List<? extends TypeDescriptor> getParameterTypes()

Returns the types of Snippet formal parameters.

Returns:List<? extends TypeDescriptor>

the parameter types

Since
0.30
getResultVerifierback to summary
public ResultVerifier getResultVerifier()

Returns the ResultVerifier to verify the execution result.

Returns:ResultVerifier

either a custom or the default ResultVerifier.

Since
0.30
See Also
ResultVerifier#accept(org.graalvm.polyglot.tck.ResultVerifier.SnippetRun).
getReturnTypeback to summary
public TypeDescriptor getReturnType()

Returns the Snippet return type.

Returns:TypeDescriptor

the return type

Since
0.30
newBuilderback to summary
public static Snippet.Builder newBuilder(final String id, final Value executableValue, final TypeDescriptor executableReturnType)

Creates a new Snippet builder object.

Parameters
id:String

the Snippet identifier The Snippets from a single LanguageProvider with the same identifier but different types are treated as overloads.

executableValue:Value

the executable Value used to execute the Snippet

executableReturnType:TypeDescriptor

the Snippet return type

Returns:Snippet.Builder

the new Builder

Since
0.30
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.

Returns:String

a string representation of the object

Annotations
@Override
Since
0.30
org.graalvm.polyglot.tck back to summary

public final Class Snippet.Builder

extends Object
Class Inheritance

The builder of a Snippet.
Since
0.30

Field Summary

Modifier and TypeField and Description
private TypeDescriptor
private final Value
private final String
private List<TypeDescriptor>
private ResultVerifier

Constructor Summary

AccessConstructor and Description
private
Builder(final String id, final Value executableValue, final TypeDescriptor executableReturnType)

Method Summary

Modifier and TypeMethod and Description
public Snippet

Returns:

the Snippet
build
()

Creates a new Snippet configured by this Builder.

public Snippet.Builder

Returns:

this Builder
parameterTypes
(final TypeDescriptor...
the types of Snippet's parameters
parameterTypes
)

Sets the Snippet formal parameter types.

public Snippet.Builder

Returns:

this Builder
resultVerifier
(final ResultVerifier
the custom ResultVerifier
resultVerifier
)

Sets a custom verifier of a result of the Snippet execution.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

executableReturnTypeback to summary
private TypeDescriptor executableReturnType
executableValueback to summary
private final Value executableValue
idback to summary
private final String id
parameterTypesback to summary
private List<TypeDescriptor> parameterTypes
verifierback to summary
private ResultVerifier verifier

Constructor Detail

Builderback to summary
private Builder(final String id, final Value executableValue, final TypeDescriptor executableReturnType)

Method Detail

buildback to summary
public Snippet build()

Creates a new Snippet configured by this Builder.

Returns:Snippet

the Snippet

Since
0.30
parameterTypesback to summary
public Snippet.Builder parameterTypes(final TypeDescriptor... parameterTypes)

Sets the Snippet formal parameter types.

Parameters
parameterTypes:TypeDescriptor[]

the types of Snippet's parameters

Returns:Snippet.Builder

this Builder

Since
0.30
resultVerifierback to summary
public Snippet.Builder resultVerifier(final ResultVerifier resultVerifier)

Sets a custom verifier of a result of the Snippet execution.

Parameters
resultVerifier:ResultVerifier

the custom ResultVerifier

Returns:Snippet.Builder

this Builder

Since
0.30
See Also
ResultVerifier#accept(org.graalvm.polyglot.tck.ResultVerifier.SnippetRun).