Package: org.codehaus.groovy.ast.stmt

## [Java] Class CaseStatement

- org.codehaus.groovy.ast.stmt.CaseStatement

-     public class CaseStatement
      extends Statement

  Represents a case arm of a SwitchStatement or a SwitchExpression. A case consists of a pattern (expression) to match against the switch selector and the statement to execute if the pattern matches.

  See Also:
    SwitchStatement
    Statement

- - ### Constructor Summary

    Constructors
    Constructor and description
    `CaseStatement(Expression expression, Statement code)` Constructs a case statement with the given expression pattern and code block.

  - ### Methods Summary

    Methods
    Type Params | Return Type | Name and description
    --- | --- | ---
    `` | `public Statement` | `getCode()` Returns the statement executed if this case pattern matches.
    `` | `public Expression` | `getExpression()` Returns the pattern expression matched against the switch control expression.
    `` | `public boolean` | `isArrow()` Indicates whether this case uses an arrow label (`case L ->`) rather than a colon label (`case L:`).
    `` | `public void` | `setArrow(boolean arrow)` Marks this case as an arrow label (`case L ->`) or a colon label.
    `` | `public void` | `setCode(Statement code)` Sets the statement executed if this case pattern matches.
    `` | `public void` | `setExpression(Expression e)` Sets the pattern expression matched against the switch control expression.
    `` | `public String` | `toString()`
    `` | `public void` | `visit(GroovyCodeVisitor visitor)`

  - ### Inherited Methods Summary

    Inherited Methods
    Methods inherited from class | Name
    --- | ---
    `class Statement` | `addStatementAnnotation, addStatementLabel, copyStatementLabels, getStatementAnnotations, getStatementLabel, getStatementLabels, isEmpty, setStatementLabel`
    `class ASTNode` | `copyNodeMetaData, getColumnNumber, getLastColumnNumber, getLastLineNumber, getLineNumber, getMetaDataMap, getText, setColumnNumber, setLastColumnNumber, setLastLineNumber, setLineNumber, setMetaDataMap, setSourcePosition, visit`

- - ### Constructor Detail

    - #### public CaseStatement(Expression expression, Statement code)

      Constructs a case statement with the given expression pattern and code block.

      Parameters:
        `expression` - the Expression pattern to match against the switch control expression
        `code` - the Statement to execute if the pattern matches

  - ### Method Detail

    - #### public Statement getCode()

      Returns the statement executed if this case pattern matches.

      Returns:
        the Statement associated with this case

    - #### public Expression getExpression()

      Returns the pattern expression matched against the switch control expression.

      Returns:
        the pattern Expression

    - #### public boolean isArrow()

      Indicates whether this case uses an arrow label (`case L ->`) rather than a colon label (`case L:`). Arrow labels do not fall through (JEP 361).

      Returns:
        `true` if this case was written with `->`
      Since:
        6.0.0

    - #### public void setArrow(boolean arrow)

      Marks this case as an arrow label (`case L ->`) or a colon label.

      Parameters:
        `arrow` - `true` if this case was written with `->`
      Since:
        6.0.0

    - #### public void setCode(Statement code)

      Sets the statement executed if this case pattern matches.

      Parameters:
        `code` - the Statement to execute

    - #### public void setExpression(Expression e)

      Sets the pattern expression matched against the switch control expression.

      Parameters:
        `e` - the pattern Expression

    - #### public String toString()

    - #### public void visit(GroovyCodeVisitor visitor)