Snippet.Kind (Java SE 19 & JDK 19) (original) (raw)
All Implemented Interfaces:
[Serializable](../../../java.base/java/io/Serializable.html "interface in java.io")
, [Comparable](../../../java.base/java/lang/Comparable.html "interface in java.lang")<[Snippet.Kind](Snippet.Kind.html "enum class in jdk.jshell")>
, [Constable](../../../java.base/java/lang/constant/Constable.html "interface in java.lang.constant")
Enclosing class:
[Snippet](Snippet.html "class in jdk.jshell")
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.
Nested Class Summary
Enum Constant Summary
Enum Constants
A syntactically incorrect input for which the specific kind could not be determined.
An expression, with or without side-effects.
An import declaration: import
...
One variable declaration.
Method Summary
boolean
Indicates whether this Kind
of Snippet is persistent.
Returns the enum constant of this class with the specified name.[values](#values%28%29)()
Returns an array containing the constants of this enum class, in the order they are declared.
Methods declared in class java.lang.Enum
[clone](../../../java.base/java/lang/Enum.html#clone%28%29), [compareTo](../../../java.base/java/lang/Enum.html#compareTo%28E%29), [describeConstable](../../../java.base/java/lang/Enum.html#describeConstable%28%29), [equals](../../../java.base/java/lang/Enum.html#equals%28java.lang.Object%29), [finalize](../../../java.base/java/lang/Enum.html#finalize%28%29), [getDeclaringClass](../../../java.base/java/lang/Enum.html#getDeclaringClass%28%29), [hashCode](../../../java.base/java/lang/Enum.html#hashCode%28%29), [name](../../../java.base/java/lang/Enum.html#name%28%29), [ordinal](../../../java.base/java/lang/Enum.html#ordinal%28%29), [toString](../../../java.base/java/lang/Enum.html#toString%28%29), [valueOf](../../../java.base/java/lang/Enum.html#valueOf%28java.lang.Class,java.lang.String%29)
Enum Constant Details
IMPORT
See Java Language Specification:
7.5 Import DeclarationsTYPE_DECL
See Java Language Specification:
7.6 Top Level Type DeclarationsMETHOD
A method declaration. The snippet is an instance of MethodSnippet.
A method declaration is persistent.
See Java Language Specification:
8.4 Method DeclarationsVAR
One variable declaration. Corresponding to one VariableDeclarator. The snippet is an instance of VarSnippet.
The variable may be with or without initializer, or be a temporary variable representing an expression -- seeSnippet.SubKindto differentiate.
A variable declaration is persistent.
See Java Language Specification:
8.3 Field DeclarationsEXPRESSION
An expression, with or without side-effects. The snippet is an instance of ExpressionSnippet.
The expression is currently either a simple named reference to a variable (Snippet.SubKind.VAR_VALUE_SUBKIND) or an assignment (both of which have natural referencing names) -- see Snippet.SubKind to differentiate. All other expression forms (operators, method calls, ...) generate a scratch variable and so are instead of the VAR Kind.
See Java Language Specification:
15 ExpressionsSTATEMENT
See Java Language Specification:
14.5 StatementsERRONEOUS
A syntactically incorrect input for which the specific kind could not be determined. The snippet is an instance of ErroneousSnippet.
Method Details
values
Returns an array containing the constants of this enum class, in the order they are declared.
Returns:
an array containing the constants of this enum class, in the order they are declaredvalueOf
Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (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](../../../java.base/java/lang/IllegalArgumentException.html "class in java.lang")
- if this enum class has no constant with the specified name
[NullPointerException](../../../java.base/java/lang/NullPointerException.html "class in java.lang")
- if the argument is nullisPersistent
public boolean isPersistent()
Indicates whether thisKind
of Snippet is persistent. Only declarations are persistent because they influence future Snippets.
Note that though theKind
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 thisKind
ofSnippet
is visible to subsequent evaluations; otherwisefalse