AssertStatementCreationUtility (Groovy 4.0.15)
Description: declaration: package: org.apache.groovy.contracts.generation, class: AssertStatementCreationUtility

Package org.apache.groovy.contracts.generation

# Class AssertStatementCreationUtility

java.lang.Object
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
  Modifier and Type
  Class
  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.

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `AssertStatementCreationUtility()`

- ## Method Summary

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

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Constructor Details

  - ### AssertStatementCreationUtility

    public AssertStatementCreationUtility()

- ## Method Details

  - ### getAssertionStatements

    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`

  - ### getAssertionStatement

    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`

  - ### getReturnStatements

    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`

  - ### injectResultVariableReturnStatementAndAssertionCallStatement

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

  - ### addAssertionCallStatementToReturnStatement

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