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 and description |
|---|
CaseStatement(Expression expression, Statement code)Constructs a case statement with the given expression pattern and code block. |
| 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 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) |
| 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 |
Constructs a case statement with the given expression pattern and code block.
expression - the Expression pattern to match against the switch control expressioncode - the Statement to execute if the pattern matchesReturns the statement executed if this case pattern matches.
Returns the pattern expression matched against the switch control expression.
Sets the statement executed if this case pattern matches.
code - the Statement to executeSets the pattern expression matched against the switch control expression.
e - the pattern ExpressionCopyright © 2003-2026 The Apache Software Foundation. All rights reserved.