public class SnippetEvent extends Object
A description of a change to a Snippet. These are generated by direct changes to state with
JShell.drop(Snippet), or indirectly by these same methods as dependencies change or Snippets are overwritten. For direct changes, the
SnippetEvent is immutable: an access to
any of its methods will always return the same result.
and thus is thread-safe.
Method SummaryModifier and TypeMethodDescriptionEither the snippet whose change caused this update or
booleanIndicates whether the signature has changed.The status before the transition.
snippet()The Snippet which has changed
status()The after status.
toString()Return a string representation of the event
value()The result value of successful run.
snippetpublic Snippet snippet()The Snippet which has changed
- the return the Snippet whose
previousStatuspublic Snippet.Status previousStatus()The status before the transition. If this event describes a Snippet creation return
- the previousStatus
statuspublic Snippet.Status status()The after status. Note: this may be the same as the previous status (not all changes cause a
- the status
isSignatureChangepublic 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 always
falseas responsibility for the definition has passed to the overwriting definition.
trueif the signature changed; otherwise
causeSnippetpublic Snippet causeSnippet()Either the snippet whose change caused this update or
null. This returns
nullif this change is the creation of a new Snippet via
evalor it is the explicit drop of a Snippet with
- the Snippet which caused this change or
nullif directly caused by an API action.
exceptionpublic JShellException exception()An instance of
UnresolvedReferenceException, if an unresolved reference was encountered, or an instance of
EvalExceptionif an exception was thrown during execution, otherwise
- the exception or
valuepublic String value()The result value of successful run. The value is null if not executed or an exception was thrown.
- the value or
toStringpublic String toString()Return a string representation of the event