Package org.codehaus.groovy.ast.stmt

# Class CaseStatement

java.lang.Object
org.codehaus.groovy.ast.ASTNode
org.codehaus.groovy.ast.stmt.Statement
org.codehaus.groovy.ast.stmt.CaseStatement

All Implemented Interfaces:
  `NodeMetaDataHandler`

public class CaseStatement extends Statement
Represents a case statement within a `SwitchStatement`. A case statement consists of a pattern (expression) to match against the switch control expression and the statement to execute if the pattern matches. In Groovy, case patterns support various expression types for flexible matching behavior.

- ## Constructor Summary

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

- ## Method Summary

  Modifier and Type
  Method
  Description
  `Statement`
  `getCode()`
  Returns the statement executed if this case pattern matches.
  `Expression`
  `getExpression()`
  Returns the pattern expression matched against the switch control expression.
  `void`
  `setCode(Statement code)`
  Sets the statement executed if this case pattern matches.
  `void`
  `setExpression(Expression e)`
  Sets the pattern expression matched against the switch control expression.
  `String`
  `toString()`
  `void`
  `visit(GroovyCodeVisitor visitor)`
  Accepts a code visitor for AST traversal and transformation.

  ### Methods inherited from class org.codehaus.groovy.ast.stmt.Statement

  `addStatementAnnotation, addStatementLabel, copyStatementLabels, getStatementAnnotations, getStatementLabel, getStatementLabels, isEmpty, setStatementLabel`

  ### Methods inherited from class org.codehaus.groovy.ast.ASTNode

  `copyNodeMetaData, getColumnNumber, getLastColumnNumber, getLastLineNumber, getLineNumber, getMetaDataMap, getText, setColumnNumber, setLastColumnNumber, setLastLineNumber, setLineNumber, setMetaDataMap, setSourcePosition`

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

  ### Methods inherited from interface org.codehaus.groovy.ast.NodeMetaDataHandler

  `copyNodeMetaData, getNodeMetaData, getNodeMetaData, getNodeMetaData, newMetaDataMap, putNodeMetaData, removeNodeMetaData, setNodeMetaData`

- ## Constructor Details

  - ### CaseStatement

    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 Details

  - ### getCode

    public Statement getCode()
    Returns the statement executed if this case pattern matches.
    Returns:
      the `Statement` associated with this case

  - ### setCode

    public void setCode(Statement code)
    Sets the statement executed if this case pattern matches.
    Parameters:
      `code` - the `Statement` to execute

  - ### getExpression

    public Expression getExpression()
    Returns the pattern expression matched against the switch control expression.
    Returns:
      the pattern `Expression`

  - ### setExpression

    public void setExpression(Expression e)
    Sets the pattern expression matched against the switch control expression.
    Parameters:
      `e` - the pattern `Expression`

  - ### visit

    public void visit(GroovyCodeVisitor visitor)
    Description copied from class: `ASTNode`
    Accepts a code visitor for AST traversal and transformation. Subclasses must implement this method to support visitor pattern-based processing. The visitor pattern enables decoupling of AST structure from processing logic.
    Overrides:
      `visit` in class `ASTNode`
    Parameters:
      `visitor` - the `GroovyCodeVisitor` to process this node

  - ### toString

    public String toString()
    Overrides:
      `toString` in class `Object`