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
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
ConstructorsConstructorDescriptionCaseStatement(Expression expression, Statement code) Constructs a case statement with the given expression pattern and code block. -
Method Summary
Modifier and TypeMethodDescriptiongetCode()Returns the statement executed if this case pattern matches.Returns the pattern expression matched against the switch control expression.voidSets the statement executed if this case pattern matches.voidSets the pattern expression matched against the switch control expression.toString()voidvisit(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, setStatementLabelMethods inherited from class org.codehaus.groovy.ast.ASTNode
copyNodeMetaData, getColumnNumber, getLastColumnNumber, getLastLineNumber, getLineNumber, getMetaDataMap, getText, setColumnNumber, setLastColumnNumber, setLastLineNumber, setLineNumber, setMetaDataMap, setSourcePositionMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.codehaus.groovy.ast.NodeMetaDataHandler
copyNodeMetaData, getNodeMetaData, getNodeMetaData, getNodeMetaData, newMetaDataMap, putNodeMetaData, removeNodeMetaData, setNodeMetaData
-
Constructor Details
-
CaseStatement
Constructs a case statement with the given expression pattern and code block.- Parameters:
expression- theExpressionpattern to match against the switch control expressioncode- theStatementto execute if the pattern matches
-
-
Method Details
-
getCode
Returns the statement executed if this case pattern matches.- Returns:
- the
Statementassociated with this case
-
setCode
Sets the statement executed if this case pattern matches.- Parameters:
code- theStatementto execute
-
getExpression
Returns the pattern expression matched against the switch control expression.- Returns:
- the pattern
Expression
-
setExpression
Sets the pattern expression matched against the switch control expression.- Parameters:
e- the patternExpression
-
visit
Description copied from class:ASTNodeAccepts 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:
visitin classASTNode- Parameters:
visitor- theGroovyCodeVisitorto process this node
-
toString
-