Package: org.apache.groovy.contracts.domain

## [Java] Class Contract

- org.apache.groovy.contracts.domain.Contract

-     public class Contract
      extends Object

  Represents a contract between a supplier and a customer of a class.

- - ### Constructor Summary

    Constructors
    Constructor and description
    `Contract(ClassNode classNode)` Creates a contract model for the supplied class.

  - ### Methods Summary

    Methods
    Type Params | Return Type | Name and description
    --- | --- | ---
    `` | `public ClassInvariant` | `classInvariant()` Returns the current class invariant.
    `` | `public ClassNode` | `classNode()` Returns the class represented by this contract.
    `` | `public boolean` | `hasDefaultClassInvariant()` Indicates whether the contract still uses the shared default class invariant.
    `` | `public AssertionMap<Postcondition>` | `postconditions()` Returns the postconditions indexed by method.
    `` | `public AssertionMap<Precondition>` | `preconditions()` Returns the preconditions indexed by method.
    `` | `public void` | `setClassInvariant(ClassInvariant classInvariant)` Replaces the class invariant associated with this contract.

  - ### Inherited Methods Summary

    Inherited Methods
    Methods inherited from class | Name
    --- | ---
    `class Object` | `equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### public Contract(ClassNode classNode)

      Creates a contract model for the supplied class.

      Parameters:
        `classNode` - the class described by this contract

  - ### Method Detail

    - #### public ClassInvariant classInvariant()

      Returns the current class invariant.

      Returns:
        the configured class invariant

    - #### public ClassNode classNode()

      Returns the class represented by this contract.

      Returns:
        the contracted class node

    - #### public boolean hasDefaultClassInvariant()

      Indicates whether the contract still uses the shared default class invariant.

      Returns:
        `true` if no custom class invariant has been set

    - #### public AssertionMap<Postcondition> postconditions()

      Returns the postconditions indexed by method.

      Returns:
        the postcondition map

    - #### public AssertionMap<Precondition> preconditions()

      Returns the preconditions indexed by method.

      Returns:
        the precondition map

    - #### public void setClassInvariant(ClassInvariant classInvariant)

      Replaces the class invariant associated with this contract.

      Parameters:
        `classInvariant` - the invariant to store