- java.lang.Object
-
- jdk.jshell.SnippetEvent
-
public class SnippetEvent extends Object
A description of a change to a Snippet. These are generated by direct changes to state withJShell.eval(String)
orJShell.drop(Snippet)
, or indirectly by these same methods as dependencies change or Snippets are overwritten. For direct changes, thecauseSnippet()
isnull
.SnippetEvent
is immutable: an access to any of its methods will always return the same result. and thus is thread-safe.- Since:
- 9
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Snippet
causeSnippet()
Either the snippet whose change caused this update ornull
.JShellException
exception()
An instance ofUnresolvedReferenceException
, if an unresolved reference was encountered, or an instance ofEvalException
if an exception was thrown during execution, otherwisenull
.boolean
isSignatureChange()
Indicates whether the signature has changed.Snippet.Status
previousStatus()
The status before the transition.Snippet
snippet()
The Snippet which has changedSnippet.Status
status()
The after status.String
toString()
Return a string representation of the eventString
value()
The result value of successful run.
-
-
-
Method Detail
-
snippet
public Snippet snippet()
The Snippet which has changed- Returns:
- the return the Snippet whose
Status
has changed.
-
previousStatus
public Snippet.Status previousStatus()
The status before the transition. If this event describes a Snippet creation returnNONEXISTENT
.- Returns:
- the previousStatus
-
status
public Snippet.Status status()
The after status. Note: this may be the same as the previous status (not all changes cause aStatus
change.- Returns:
- the status
-
isSignatureChange
public boolean isSignatureChange()
Indicates whether the signature has changed. Coming in or out of definition is always a signature change. An overwritten Snippet(status == OVERWRITTEN)
is alwaysfalse
as responsibility for the definition has passed to the overwriting definition.- Returns:
true
if the signature changed; otherwisefalse
-
causeSnippet
public Snippet causeSnippet()
Either the snippet whose change caused this update ornull
. This returnsnull
if this change is the creation of a new Snippet viaeval
or it is the explicit drop of a Snippet withdrop
.- Returns:
- the Snippet which caused this change or
null
if directly caused by an API action.
-
exception
public JShellException exception()
An instance ofUnresolvedReferenceException
, if an unresolved reference was encountered, or an instance ofEvalException
if an exception was thrown during execution, otherwisenull
.- Returns:
- the exception or
null
.
-
value
public String value()
The result value of successful run. The value is null if not executed or an exception was thrown.- Returns:
- the value or
null
.
-
-