Package: org.codehaus.groovy.ast.stmt

## [Java] Class AssertStatement

- org.codehaus.groovy.ast.stmt.AssertStatement

-     public class AssertStatement
      extends Statement

  Represents an assert statement that enforces a condition with an optional error message. An assert statement evaluates a boolean condition and throws an `AssertionError` if the condition is false. An optional message expression may be provided to customize the error message. Assert statements are typically used to verify invariants and debug assumptions.

  Example: `assert i != 0 : "should never be zero"`

  See Also:
    BooleanExpression
    Expression
    Statement

- - ### Constructor Summary

    Constructors
    Constructor and description
    `AssertStatement(BooleanExpression booleanExpression)` Constructs an assert statement with the given condition and no message.
    `AssertStatement(BooleanExpression booleanExpression, Expression messageExpression)` Constructs an assert statement with the given condition and message expression.

  - ### Methods Summary

    Methods
    Type Params | Return Type | Name and description
    --- | --- | ---
    `` | `public BooleanExpression` | `getBooleanExpression()` Returns the boolean condition to be asserted.
    `` | `public Expression` | `getMessageExpression()` Returns the message expression that provides an optional error message.
    `` | `public void` | `setBooleanExpression(BooleanExpression booleanExpression)` Sets the boolean condition to be asserted.
    `` | `public void` | `setMessageExpression(Expression messageExpression)` Sets the message expression that provides an optional error message.
    `` | `public void` | `visit(GroovyCodeVisitor visitor)`

  - ### Inherited Methods Summary

    Inherited Methods
    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`

- - ### Constructor Detail

    - #### public AssertStatement(BooleanExpression booleanExpression)

      Constructs an assert statement with the given condition and no message.

      Parameters:
        `booleanExpression` - the BooleanExpression condition to assert

    - #### public AssertStatement(BooleanExpression booleanExpression, Expression messageExpression)

      Constructs an assert statement with the given condition and message expression.

      Parameters:
        `booleanExpression` - the BooleanExpression condition to assert
        `messageExpression` - the Expression that evaluates to an optional error message; if null or a null expression, no custom message is used

  - ### Method Detail

    - #### public BooleanExpression getBooleanExpression()

      Returns the boolean condition to be asserted.

      Returns:
        the BooleanExpression to evaluate

    - #### public Expression getMessageExpression()

      Returns the message expression that provides an optional error message.

      Returns:
        the Expression that evaluates to the error message, or a null expression if not provided

    - #### public void setBooleanExpression(BooleanExpression booleanExpression)

      Sets the boolean condition to be asserted.

      Parameters:
        `booleanExpression` - the BooleanExpression to evaluate

    - #### public void setMessageExpression(Expression messageExpression)

      Sets the message expression that provides an optional error message.

      Parameters:
        `messageExpression` - the Expression that evaluates to the error message

    - #### public void visit(GroovyCodeVisitor visitor)