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

public final Class InlineSnippet

extends Object
Class Inheritance
Imports
java.util.Objects, java.util.function.Predicate, org.graalvm.polyglot.SourceSection, .Value

The unit of execution with an inline source. The InlineSnippet represents an execution of a script and an associated inline source code that is to be executed at script's locations.

It's recommended to provide two snippets at least, one with local variables and restricted location predicate and one with globally accessible code and no location predicate.

Since
0.32

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class

Field Summary

Modifier and TypeField and Description
private final CharSequence
private final Predicate<SourceSection>
private final Snippet
private final ResultVerifier

Constructor Summary

AccessConstructor and Description
private
InlineSnippet(final Snippet script, final CharSequence source, final Predicate<SourceSection> locationPredicate, final ResultVerifier verifier)

Method Summary

Modifier and TypeMethod and Description
public CharSequence
getCode()

Returns an inline source code that is to be executed at specific locations, or at all statement and call locations if the predicate is null.

public Predicate<SourceSection>

Returns:

the predicate that returns true for SourceSections where the source code is to be executed, or null if the source code should be executed at all instrumentable statement and call locations.
getLocationPredicate
()

Returns a testing predicate for locations at which source code is executed.

public ResultVerifier

Returns:

either a custom or the default ResultVerifier.
getResultVerifier
()

Returns the ResultVerifier to verify the result of source code execution.

public Snippet
getScript()

Returns a script to be executed.

public static InlineSnippet.Builder

Returns:

the new Builder
newBuilder
(final Snippet
the script to execute (use Snippet#newBuilder(String, Value, TypeDescriptor) to create one)
script
,
final CharSequence
the inline source code that is to be executed inside the script
code
)

Creates a new InlineSnippet 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

codeback to summary
private final CharSequence code
locationPredicateback to summary
private final Predicate<SourceSection> locationPredicate
scriptback to summary
private final Snippet script
verifierback to summary
private final ResultVerifier verifier

Constructor Detail

InlineSnippetback to summary
private InlineSnippet(final Snippet script, final CharSequence source, final Predicate<SourceSection> locationPredicate, final ResultVerifier verifier)

Method Detail

getCodeback to summary
public CharSequence getCode()

Returns an inline source code that is to be executed at specific locations, or at all statement and call locations if the predicate is null.

Since
0.32
getLocationPredicateback to summary
public Predicate<SourceSection> getLocationPredicate()

Returns a testing predicate for locations at which source code is executed.

Returns:Predicate<SourceSection>

the predicate that returns true for SourceSections where the source code is to be executed, or null if the source code should be executed at all instrumentable statement and call locations.

Since
0.32
getResultVerifierback to summary
public ResultVerifier getResultVerifier()

Returns the ResultVerifier to verify the result of source code execution.

Returns:ResultVerifier

either a custom or the default ResultVerifier.

Since
0.32
See Also
ResultVerifier#accept(org.graalvm.polyglot.tck.ResultVerifier.SnippetRun).
getScriptback to summary
public Snippet getScript()

Returns a script to be executed. The source code is executed inlined in this script.

Since
0.32
newBuilderback to summary
public static InlineSnippet.Builder newBuilder(final Snippet script, final CharSequence code)

Creates a new InlineSnippet builder object.

Parameters
script:Snippet

the script to execute (use Snippet#newBuilder(String, Value, TypeDescriptor) to create one)

code:CharSequence

the inline source code that is to be executed inside the script

Returns:InlineSnippet.Builder

the new Builder

Since
0.32
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.32
org.graalvm.polyglot.tck back to summary

public final Class InlineSnippet.Builder

extends Object
Class Inheritance

The builder of an InlineSnippet.
Since
0.32

Field Summary

Modifier and TypeField and Description
private final CharSequence
private Predicate<SourceSection>
private final Snippet
private ResultVerifier

Constructor Summary

AccessConstructor and Description
private
Builder(final Snippet script, final CharSequence code)

Method Summary

Modifier and TypeMethod and Description
public InlineSnippet

Returns:

the InlineSnippet
build
()

Creates a new InlineSnippet configured by this Builder.

public InlineSnippet.Builder

Returns:

the predicate that returns true for SourceSections where source is to be executed
locationPredicate
(final Predicate<SourceSection> locationPredicate)

Sets a testing predicate for locations at which the source is executed.

public InlineSnippet.Builder

Returns:

this Builder
resultVerifier
(final ResultVerifier
the custom ResultVerifier
resultVerifier
)

Sets a custom verifier of a result of the inline source execution.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

codeback to summary
private final CharSequence code
predicateback to summary
private Predicate<SourceSection> predicate
scriptback to summary
private final Snippet script
verifierback to summary
private ResultVerifier verifier

Constructor Detail

Builderback to summary
private Builder(final Snippet script, final CharSequence code)

Method Detail

buildback to summary
public InlineSnippet build()

Creates a new InlineSnippet configured by this Builder.

Returns:InlineSnippet

the InlineSnippet

Since
0.32
locationPredicateback to summary
public InlineSnippet.Builder locationPredicate(final Predicate<SourceSection> locationPredicate)

Sets a testing predicate for locations at which the source is executed. By default, the source is executed at all instrumentable statement and call locations in the script.

Returns:InlineSnippet.Builder

the predicate that returns true for SourceSections where source is to be executed

Since
0.32
resultVerifierback to summary
public InlineSnippet.Builder resultVerifier(final ResultVerifier resultVerifier)

Sets a custom verifier of a result of the inline source execution.

Parameters
resultVerifier:ResultVerifier

the custom ResultVerifier

Returns:InlineSnippet.Builder

this Builder

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