Module jdk.jshell
Package jdk.jshell

Enum Snippet.Kind

  • All Implemented Interfaces:
    Serializable, Comparable<Snippet.Kind>
    Enclosing class:
    Snippet

    public static enum Snippet.Kind
    extends Enum<Snippet.Kind>
    Describes the general kind of snippet. The Kind is an immutable property of a Snippet. It is accessed with Snippet.kind(). The Kind can be used to determine which subclass of Snippet it is. For example, eval("int three() { return 3; }") will return a snippet creation event. The Kind of that Snippet will be METHOD, from which you know that the subclass of Snippet is MethodSnippet and it can be cast as such.
    • Method Detail

      • values

        public static Snippet.Kind[] values()
        Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:
        for (Snippet.Kind c : Snippet.Kind.values())
            System.out.println(c);
        
        Returns:
        an array containing the constants of this enum type, in the order they are declared
      • valueOf

        public static Snippet.Kind valueOf​(String name)
        Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)
        Parameters:
        name - the name of the enum constant to be returned.
        Returns:
        the enum constant with the specified name
        Throws:
        IllegalArgumentException - if this enum type has no constant with the specified name
        NullPointerException - if the argument is null
      • isPersistent

        public boolean isPersistent()
        Indicates whether this Kind of Snippet is persistent. Only declarations are persistent because they influence future Snippets.

        Note that though the Kind of a Snippet may be persistent, that does not mean that the Snippet will persist; For example it may be invalid or have been dropped. See: Snippet.Status.isDefined().

        Returns:
        true if this Kind of Snippet is visible to subsequent evaluations; otherwise false