APIdia Launch Partner
Top Description Inners Methods
com.sun.source.tree

public Interface CaseTree

extends Tree
Known Direct Implementers
com.sun.tools.javac.tree.JCTree.JCCase
Imports
java.util.List

A tree node for a case in a switch statement or expression. For example:
  case expression :
      statements

  default :
      statements
Authors
Peter von der Ahé, Jonathan Gibbons
Since
1.6
Java Language Specification
14.11 The switch Statement

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static enum
CaseTree.CaseKind

The syntactic form of this case:

  • STATEMENT: case <expression>: <statements>
  • RULE: case <expression> -> <expression>/<statement>

Method Summary

Modifier and TypeMethod and Description
public default Tree

Returns:

case value or null
getBody
()

For case with kind CaseKind#RULE, returns the statement or expression after the arrow.

public default CaseTree.CaseKind

Returns:

the kind of this case
getCaseKind
()

Returns the kind of this case.

public ExpressionTree

Returns:

the expression for the case, or null
getExpression
()
Deprecated Please use getExpressions().

Returns the expression for the case, or null if this is the default case.

public List<? extends ExpressionTree>

Returns:

labels for this case
getExpressions
()

Returns the labels for this case.

public ExpressionTree

Returns:

the guard
getGuard
()

The guard for the case.

public List<? extends CaseLabelTree>

Returns:

labels for this case
getLabels
()

Returns the labels for this case.

public List<? extends StatementTree>

Returns:

the statements labeled by the case or null
getStatements
()

For case with kind CaseKind#STATEMENT, returns the statements labeled by the case.

Inherited from com.sun.source.tree.Tree:
acceptgetKind

Method Detail

getBodyback to summary
public default Tree getBody()

For case with kind CaseKind#RULE, returns the statement or expression after the arrow. Returns null for case with kind CaseKind#STATEMENT.

Returns:Tree

case value or null

Since
14
getCaseKindback to summary
public default CaseTree.CaseKind getCaseKind()

Returns the kind of this case.

Returns:CaseTree.CaseKind

the kind of this case

Since
14
getExpressionback to summary
public ExpressionTree getExpression()

Deprecated

Please use getExpressions().

Returns the expression for the case, or null if this is the default case. If this case has multiple labels, returns the first label.

Returns:ExpressionTree

the expression for the case, or null

Annotations
@Deprecated
getExpressionsback to summary
public List<? extends ExpressionTree> getExpressions()

Returns the labels for this case. For default case, returns an empty list.

Returns:List<? extends ExpressionTree>

labels for this case

Since
14
getGuardback to summary
public ExpressionTree getGuard()

The guard for the case.

Returns:ExpressionTree

the guard

Since
21
getLabelsback to summary
public List<? extends CaseLabelTree> getLabels()

Returns the labels for this case. For default case return a list with a single element, DefaultCaseLabelTree.

Returns:List<? extends CaseLabelTree>

labels for this case

Since
21
getStatementsback to summary
public List<? extends StatementTree> getStatements()

For case with kind CaseKind#STATEMENT, returns the statements labeled by the case. Returns null for case with kind CaseKind#RULE.

Returns:List<? extends StatementTree>

the statements labeled by the case or null

com.sun.source.tree back to summary

public final Enum CaseTree.CaseKind

extends Enum<CaseTree.CaseKind>
Class Inheritance

The syntactic form of this case:
Since
14

Field Summary

Modifier and TypeField and Description
public static final CaseTree.CaseKind
RULE

Case is in the form: case <expression> -> <expression>.

public static final CaseTree.CaseKind
STATEMENT

Case is in the form: case <expression>: <statements>.

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static CaseTree.CaseKind
public static CaseTree.CaseKind[]
Inherited from java.lang.Enum:
clonecompareTodescribeConstableequalsfinalizegetDeclaringClasshashCodenameordinaltoStringvalueOf

Field Detail

RULEback to summary
public static final CaseTree.CaseKind RULE

Case is in the form: case <expression> -> <expression>.

STATEMENTback to summary
public static final CaseTree.CaseKind STATEMENT

Case is in the form: case <expression>: <statements>.

Constructor Detail

CaseKindback to summary
private CaseKind()

Method Detail

valueOfback to summary
public static CaseTree.CaseKind valueOf(String name)
valuesback to summary
public static CaseTree.CaseKind[] values()