Package org.codehaus.groovy.ast.stmt

# Class DoWhileStatement

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

All Implemented Interfaces:
  `NodeMetaDataHandler`, `LoopingStatement`

public class DoWhileStatement extends Statement implements LoopingStatement
Represents a do { ... } while (condition) loop in Groovy. A do-while loop executes its body unconditionally on the first iteration, then evaluates a `BooleanExpression` after each iteration to decide whether to repeat. The loop body always executes at least once, differentiating it from a `WhileStatement`.

See Also:
  - `LoopingStatement`
  - `Statement`
  - `BooleanExpression`
  - `WhileStatement`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `DoWhileStatement(BooleanExpression booleanExpression, Statement loopBlock)`
  Constructs a DoWhileStatement with a loop body and condition.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `BooleanExpression`
  `getBooleanExpression()`
  Returns the `BooleanExpression`} evaluated after each iteration.
  `Statement`
  `getLoopBlock()`
  Returns the loop body `Statement`}.
  `void`
  `setBooleanExpression(BooleanExpression booleanExpression)`
  Sets the `BooleanExpression`} to evaluate after each iteration.
  `void`
  `setLoopBlock(Statement loopBlock)`
  Sets the loop body `Statement`}.
  `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, toString, wait, wait, wait`

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

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

- ## Constructor Details

  - ### DoWhileStatement

    public DoWhileStatement(BooleanExpression booleanExpression, Statement loopBlock)
    Constructs a DoWhileStatement with a loop body and condition.
    Parameters:
      `booleanExpression` - the `BooleanExpression`} evaluated after each iteration
      `loopBlock` - the `Statement`} to execute; always runs at least once

- ## Method Details

  - ### 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

  - ### getBooleanExpression

    public BooleanExpression getBooleanExpression()
    Returns the `BooleanExpression`} evaluated after each iteration.
    Returns:
      the loop condition `BooleanExpression`}

  - ### getLoopBlock

    public Statement getLoopBlock()
    Returns the loop body `Statement`}.
    Specified by:
      `getLoopBlock` in interface `LoopingStatement`
    Returns:
      the loop block `Statement`}

  - ### setBooleanExpression

    public void setBooleanExpression(BooleanExpression booleanExpression)
    Sets the `BooleanExpression`} to evaluate after each iteration.
    Parameters:
      `booleanExpression` - the loop condition `BooleanExpression`}

  - ### setLoopBlock

    public void setLoopBlock(Statement loopBlock)
    Sets the loop body `Statement`}.
    Specified by:
      `setLoopBlock` in interface `LoopingStatement`
    Parameters:
      `loopBlock` - the loop block `Statement`}