Package org.apache.groovy.contracts.generation

# Class PostconditionGenerator

java.lang.Object
org.apache.groovy.contracts.generation.BaseGenerator
org.apache.groovy.contracts.generation.PostconditionGenerator

public class PostconditionGenerator extends BaseGenerator

Code generator for postconditions.

- ## Field Summary

  ### Fields inherited from class org.apache.groovy.contracts.generation.BaseGenerator

  `INVARIANT_CLOSURE_PREFIX, META_DATA_USE_INLINE_MODE, source`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `PostconditionGenerator(ReaderSource source)`
  Creates a generator for postcondition support code.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `void`
  `addOldVariablesMethod(ClassNode classNode)`
  Adds a synthetic method to the given `classNode` which can be used to create a map of most instance variables found in this class.
  `void`
  `generateDefaultPostconditionStatement(ClassNode type, MethodNode method)`
  Adds a default postcondition if a postcondition has already been defined for this `MethodNode` in a super-class.
  `void`
  `generatePostconditionAssertionStatement(MethodNode method, Postcondition postcondition)`
  Injects a postcondition assertion statement in the given `method`, based on the `booleanExpression`.

  ### Methods inherited from class org.apache.groovy.contracts.generation.BaseGenerator

  `addCallsToSuperMethodNodeAnnotationClosure, getInlineModeBlockStatement, getInvariantMethodName, getInvariantMethodNode, wrapAssertionBooleanExpression`

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

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

- ## Constructor Details

  - ### PostconditionGenerator

    public PostconditionGenerator(ReaderSource source)
    Creates a generator for postcondition support code.
    Parameters:
      `source` - the reader source backing the current source unit

- ## Method Details

  - ### addOldVariablesMethod

    public void addOldVariablesMethod(ClassNode classNode)
    Adds a synthetic method to the given `classNode` which can be used to create a map of most instance variables found in this class. Used for the `old` variable mechanism.
    Parameters:
      `classNode` - the `ClassNode` to add the synthetic method to

  - ### generatePostconditionAssertionStatement

    public void generatePostconditionAssertionStatement(MethodNode method, Postcondition postcondition)
    Injects a postcondition assertion statement in the given `method`, based on the `booleanExpression`.
    Parameters:
      `method` - the `MethodNode` for assertion injection
      `postcondition` - the `Postcondition` the assertion statement should be generated from

  - ### generateDefaultPostconditionStatement

    public void generateDefaultPostconditionStatement(ClassNode type, MethodNode method)
    Adds a default postcondition if a postcondition has already been defined for this `MethodNode` in a super-class.
    Parameters:
      `type` - the current `ClassNode` of the given `methodNode`
      `method` - the `MethodNode` to create the default postcondition for