# Package groovy.contracts

## Package groovy.contracts Description

Design-by-contract (DbC) support with compile-time assertion generation.

Stable annotations:

- groovy.contracts.Requires – method precondition
- @Ensures – method postcondition; closures may reference `result` and `old`
- @Invariant – class invariant, also usable as a loop invariant on `for` / `while` / `do-while` loops
- @Contracted – package- or class-level opt-in marker that enables contract processing

Incubating in 6.0.0 (semantics may evolve in a subsequent 6.x release):

- @Modifies – frame condition declaring which fields and parameters a method may modify
- @Decreases – a termination measure (a strictly-decreasing, well-founded variant) for a loop (per iteration) or a recursive method (per recursive re-entry)

- Annotation Type Summary
  Annotation Type | Description
  --- | ---
  Contracted |
  Decreases | Specifies a termination measure, either for a loop or for a (recursive) method.
  Ensures |
  EnsuresConditions | Container annotation for multiple Ensures postconditions on the same target.
  Invariant |
  Invariants | Container annotation for multiple Invariant declarations on the same type.
  Modifies | Declares the frame condition for a method: the set of fields and parameters that the method is allowed to modify.
  ModifiesConditions | Container for multiple Modifies annotations on the same method.
  Requires |
  RequiresConditions | Container annotation for multiple Requires preconditions on the same target.