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:
  • Constructor Details

    • AssertStatementCreationUtility

      public AssertStatementCreationUtility()
  • Method Details

    • getAssertionStatements

      public static org.codehaus.groovy.ast.stmt.BlockStatement getAssertionStatements(List<org.codehaus.groovy.ast.expr.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 org.codehaus.groovy.ast.stmt.AssertStatement getAssertionStatement(org.codehaus.groovy.ast.expr.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<org.codehaus.groovy.ast.stmt.ReturnStatement> getReturnStatements(org.codehaus.groovy.ast.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(org.codehaus.groovy.ast.stmt.BlockStatement statement, org.codehaus.groovy.ast.ClassNode returnType, org.codehaus.groovy.ast.stmt.ReturnStatement returnStatement, org.codehaus.groovy.ast.stmt.BlockStatement assertionCallStatement)
    • addAssertionCallStatementToReturnStatement

      public static void addAssertionCallStatementToReturnStatement(org.codehaus.groovy.ast.stmt.BlockStatement statement, org.codehaus.groovy.ast.stmt.ReturnStatement returnStatement, org.codehaus.groovy.ast.stmt.Statement assertionCallStatement)