Package: org.apache.groovy.contracts.generation

## [Java] Class ClassInvariantGenerator

- org.apache.groovy.contracts.generation.ClassInvariantGenerator

-     public class ClassInvariantGenerator
      extends BaseGenerator

  Code generator for class invariants.

- - Inherited fields
    Fields inherited from class | Fields
    --- | ---
    `class BaseGenerator` | `INVARIANT_CLOSURE_PREFIX, META_DATA_USE_INLINE_MODE, source`

  - ### Constructor Summary

    Constructors
    Constructor and description
    `ClassInvariantGenerator(ReaderSource source)` Creates a generator for class-invariant support code.

  - ### Methods Summary

    Methods
    Type Params | Return Type | Name and description
    --- | --- | ---
    `` | `public void` | `addInvariantAssertionStatement(ClassNode type, MethodNode method)` Adds the current class-invariant to the given `method`.
    `` | `public void` | `generateInvariantAssertionStatement(ClassNode type, ClassInvariant classInvariant)` Reads the Invariant boolean expression and generates a synthetic method holding this class invariant.

  - ### Inherited Methods Summary

    Inherited Methods
    Methods inherited from class | Name
    --- | ---
    `class BaseGenerator` | `addCallsToSuperMethodNodeAnnotationClosure, getInlineModeBlockStatement, getInvariantMethodName, getInvariantMethodNode, wrapAssertionBooleanExpression`

- - ### Constructor Detail

    - #### public ClassInvariantGenerator(ReaderSource source)

      Creates a generator for class-invariant support code.

      Parameters:
        `source` - the reader source backing the current source unit

  - ### Method Detail

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

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