# Class SnippetEvent

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 with `JShell.eval(String)` or `JShell.drop(Snippet)`, or indirectly by these same methods as dependencies change or Snippets are overwritten. For direct changes, the `causeSnippet()` is `null`.

`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

  Modifier and Type
  Method
  Description
  `Snippet`
  `causeSnippet()`
  Either the snippet whose change caused this update or `null`.
  `JShellException`
  `exception()`
  An instance of `UnresolvedReferenceException`, if an unresolved reference was encountered, or an instance of `EvalException` if an exception was thrown during execution, otherwise `null`.
  `boolean`
  `isSignatureChange()`
  Indicates whether the signature has changed.
  `Snippet.Status`
  `previousStatus()`
  The status before the transition.
  `Snippet`
  `snippet()`
  The Snippet which has changed
  `Snippet.Status`
  `status()`
  The after status.
  `String`
  `toString()`
  Return a string representation of the event
  `String`
  `value()`
  The result value of successful run.

  ### Methods declared in class Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`
  Modifier and Type
  Method
  Description
  `protected Object`
  `clone()`
  Creates and returns a copy of this object.
  `boolean`
  `equals(Object obj)`
  Indicates whether some other object is "equal to" this one.
  `protected void`
  `finalize()`
  Deprecated, for removal: This API element is subject to removal in a future version.
  Finalization is deprecated and subject to removal in a future release.
  `final Class<?>`
  `getClass()`
  Returns the runtime class of this `Object`.
  `int`
  `hashCode()`
  Returns a hash code value for this object.
  `final void`
  `notify()`
  Wakes up a single thread that is waiting on this object's monitor.
  `final void`
  `notifyAll()`
  Wakes up all threads that are waiting on this object's monitor.
  `final void`
  `wait()`
  Causes the current thread to wait until it is awakened, typically by being notified or interrupted.
  `final void`
  `wait(long timeoutMillis)`
  Causes the current thread to wait until it is awakened, typically by being notified or interrupted, or until a certain amount of real time has elapsed.
  `final void`
  `wait(long timeoutMillis, int nanos)`
  Causes the current thread to wait until it is awakened, typically by being notified or interrupted, or until a certain amount of real time has elapsed.

- ## Method Details

  - ### 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 return `NONEXISTENT`.
    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 a `Status` 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 always `false` as responsibility for the definition has passed to the overwriting definition.
    Returns:
      `true` if the signature changed; otherwise `false`

  - ### causeSnippet

    public Snippet causeSnippet()
    Either the snippet whose change caused this update or `null`. This returns `null` if this change is the creation of a new Snippet via `eval` or it is the explicit drop of a Snippet with `drop`.
    Returns:
      the Snippet which caused this change or `null` if directly caused by an API action.

  - ### exception

    public JShellException exception()
    An instance of `UnresolvedReferenceException`, if an unresolved reference was encountered, or an instance of `EvalException` if an exception was thrown during execution, otherwise `null`.
    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`.

  - ### toString

    public String toString()
    Return a string representation of the event
    Overrides:
      `toString` in class `Object`
    Returns:
      a descriptive representation of the SnippetEvent