Package org.apache.groovy.contracts.generation

# Class ClassInvariantGenerator

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

public class ClassInvariantGenerator extends BaseGenerator

Code generator for class invariants.

- ## 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
  `ClassInvariantGenerator(ReaderSource source)`
  Creates a generator for class-invariant support code.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `void`
  `addInvariantAssertionStatement(ClassNode type, MethodNode method)`
  Adds the current class-invariant to the given `method`.
  `void`
  `generateInvariantAssertionStatement(ClassNode type, ClassInvariant classInvariant)`
  Reads the `Invariant` boolean expression and generates a synthetic method holding this class invariant.

  ### 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

  - ### ClassInvariantGenerator

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

- ## Method Details

  - ### generateInvariantAssertionStatement

    public void generateInvariantAssertionStatement(ClassNode type, ClassInvariant classInvariant)
    Reads the `Invariant` boolean expression and generates a synthetic method holding this class invariant. This is used for heir calls to find out about inherited class invariants.
    Parameters:
      `type` - the current `ClassNode`
      `classInvariant` - the `ClassInvariant` the assertion statement should be generated from

  - ### addInvariantAssertionStatement

    public void addInvariantAssertionStatement(ClassNode type, MethodNode method)
    Adds the current class-invariant to the given `method`.
    Parameters:
      `type` - the `ClassNode` which declared the given `MethodNode`
      `method` - the current `MethodNode`