# Package org.apache.groovy.contracts

package org.apache.groovy.contracts
Provides Design by Contract (DbC) support for Groovy classes and methods. This framework allows developers to define preconditions, postconditions, and class invariants using annotations, enabling automatic runtime validation of contract constraints.

- Related Packages
  Package
  Description
  org.apache.groovy.contracts.ast
  AST transformations for implementing Design by Contract semantics, including precondition, postcondition, and invariant validation transformations.
  org.apache.groovy.contracts.domain
  Domain model classes representing contract elements such as preconditions, postconditions, and class invariants.
  org.apache.groovy.contracts.generation
  Code generation and transformation utilities for producing runtime contract validation code.
  org.apache.groovy.contracts.util
  Utility functions and helper classes for contract processing and validation.
- Class
  Description
  AssertionViolation
  Abstract base class for all assertion violations.
  CircularAssertionCallException
  Thrown whenever pre- or post-conditions are called in a cyclic way.
  ClassInvariantViolation
  Thrown whenever a class invariant violation occurs.
  LoopInvariantViolation
  Thrown whenever a loop invariant violation occurs.
  LoopVariantViolation
  Thrown whenever a loop variant (decreases/increases) violation occurs.
  MethodVariantSupport
  Runtime support for a method-level `Decreases` recursion termination measure.
  PostconditionViolation
  Thrown whenever a postcondition violation occurs.
  PreconditionViolation
  Thrown whenever a precondition violation occurs.
  RecursionVariantViolation
  Thrown when a method-level `Decreases` recursion termination measure fails — either a recursive re-entry did not strictly decrease the measure, or the measure became negative (not well-founded).
  ThrowsIfSupport
  Runtime support for `checked` `@ThrowsIf` arm-sets (invoked from generated code; not intended to be called by user code).
  ThrowsIfViolation
  Thrown whenever a `@ThrowsIf` exceptional-contract violation is detected by a `checked` arm-set: the method returned normally although a must-throw condition held, or threw a matching exception although no arm's condition held (the latter checked only for `exhaustive` arm-sets).
  VariantSupport
  Shared runtime support for `Decreases` termination measures, used by both the loop variant (`@Decreases` on a loop) and the recursion variant (`@Decreases` on a method, via `MethodVariantSupport`).
  ViolationTracker
  A violation tracker is used to keep a list of pre-, post-condition or class-invariant violations in chronological order.