AssertStatementCreationUtility (Groovy 5.0.0)

Package: org.apache.groovy.contracts.generation

## [Java] Class AssertStatementCreationUtility

- org.apache.groovy.contracts.generation.AssertStatementCreationUtility

-     public final class AssertStatementCreationUtility
      extends Object

  Central place to create AssertStatement instances in groovy-contracts. Utilized to centralize AssertionError message generation.

  See Also:
    AssertStatement
    AssertionError

- - ### Nested Class Summary

    Nested classes
    Modifiers | Name | Description
    --- | --- | ---
    `static class` | `AssertStatementCreationUtility.AddAssertionCallStatementToReturnStatementVisitor` | Replaces a given ReturnStatement with the appropriate assertion call statement and returns a result variable expression.
    `static class` | `AssertStatementCreationUtility.AddResultReturnStatementVisitor` | Replaces a given ReturnStatement with the appropriate assertion call statement and returns a result variable expression.
    `static class` | `AssertStatementCreationUtility.ReturnStatementVisitor` | Collects all ReturnStatement instances from a given code block.

  - ### Methods Summary

    Methods
    Type Params | Return Type | Name and description
    --- | --- | ---
    `` | `public static void` | `addAssertionCallStatementToReturnStatement(BlockStatement statement, ReturnStatement returnStatement, Statement assertionCallStatement)`
    `` | `public static AssertStatement` | `getAssertionStatement(BooleanExpression booleanExpression)` Reusable method for creating assert statements for the given `booleanExpression`.
    `` | `public static BlockStatement` | `getAssertionStatements(List<BooleanExpression> booleanExpressions)` Reusable method for creating assert statements for the given `booleanExpression`.
    `` | `public static List<ReturnStatement>` | `getReturnStatements(MethodNode method)` Gets a list of ReturnStatement instances from the given MethodNode.
    `` | `public static void` | `injectResultVariableReturnStatementAndAssertionCallStatement(BlockStatement statement, ClassNode returnType, ReturnStatement returnStatement, BlockStatement assertionCallStatement)`

  - ### Inherited Methods Summary

    Inherited Methods
    Methods inherited from class | Name
    --- | ---
    `class Object` | `equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Method Detail

    - #### public static void addAssertionCallStatementToReturnStatement(BlockStatement statement, ReturnStatement returnStatement, Statement assertionCallStatement)

    - #### public static AssertStatement getAssertionStatement(BooleanExpression booleanExpression)

      Reusable method for creating assert statements for the given `booleanExpression`.

      Parameters:
        `booleanExpression` - the assertion's BooleanExpression
      Returns:
        a newly created AssertStatement

    - #### public static BlockStatement getAssertionStatements(List<BooleanExpression> booleanExpressions)

      Reusable method for creating assert statements for the given `booleanExpression`.

      Parameters:
        `booleanExpressions` - the assertion's BooleanExpression instances
      Returns:
        a newly created AssertStatement

    - #### public static List<ReturnStatement> getReturnStatements(MethodNode method)

      Gets a list of ReturnStatement instances from the given MethodNode.

      Parameters:
        `method` - the MethodNode that holds the given `lastStatement`
      Returns:
        a ReturnStatement or `null`

    - #### public static void injectResultVariableReturnStatementAndAssertionCallStatement(BlockStatement statement, ClassNode returnType, ReturnStatement returnStatement, BlockStatement assertionCallStatement)