Package: org.apache.groovy.contracts.generation

## [Java] Class PreconditionGenerator

- org.apache.groovy.contracts.generation.PreconditionGenerator

-     public class PreconditionGenerator
      extends BaseGenerator

  Code generator for preconditions.

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

  - ### Constructor Summary

    Constructors
    Constructor and description
    `PreconditionGenerator(ReaderSource source)`

  - ### Methods Summary

    Methods
    Type Params | Return Type | Name and description
    --- | --- | ---
    `` | `public void` | `generateDefaultPreconditionStatement(ClassNode type, MethodNode methodNode)` Generates the default precondition statement for MethodNode instances with the Precondition annotation.
    `` | `public void` | `generatePreconditionAssertionStatement(MethodNode method, Precondition precondition)` Injects a precondition assertion statement in the given `method`, based on the given `annotation` of type Requires.

  - ### Inherited Methods Summary

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

- - ### Constructor Detail

    - #### public PreconditionGenerator(ReaderSource source)

  - ### Method Detail

    - #### public void generateDefaultPreconditionStatement(ClassNode type, MethodNode methodNode)

      Generates the default precondition statement for MethodNode instances with the Precondition annotation.

      Parameters:
        `type` - the current ClassNode
        `methodNode` - the MethodNode with a Precondition annotation

    - #### public void generatePreconditionAssertionStatement(MethodNode method, Precondition precondition)

      Injects a precondition assertion statement in the given `method`, based on the given `annotation` of type Requires.

      Parameters:
        `method` - the MethodNode for assertion injection
        `precondition` - the Precondition the assertion statement should be generated from