public class WhileStatement
extends Statement
implements LoopingStatement
Represents a while (condition) { ... } loop in Groovy. The while loop repeatedly evaluates a BooleanExpression at the start of each iteration and executes the loop body only if the condition is true. If the condition is false on the first evaluation, the loop body never executes.
| Constructor and description |
|---|
WhileStatement(BooleanExpression booleanExpression, Statement loopBlock)Constructs a WhileStatement with a condition and loop body. |
| Type Params | Return Type | Name and description |
|---|---|---|
|
public BooleanExpression |
getBooleanExpression()Returns the BooleanExpression that is evaluated at the start of each iteration. |
|
public Statement |
getLoopBlock()Returns the loop body Statement}. |
|
public void |
setBooleanExpression(BooleanExpression booleanExpression)Sets the BooleanExpression} to evaluate at the start of each iteration. |
|
public void |
setLoopBlock(Statement loopBlock)Sets the loop body Statement}. |
|
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 WhileStatement with a condition and loop body.
booleanExpression
- the BooleanExpression evaluated at the start of each iterationloopBlock
- the Statement to execute while the condition is trueReturns the BooleanExpression that is evaluated at the start of each iteration.
Sets the BooleanExpression} to evaluate at the start of each iteration.
booleanExpression
- the loop condition BooleanExpression}Sets the loop body Statement}.
loopBlock
- the loop block Statement}Copyright © 2003-2026 The Apache Software Foundation. All rights reserved.