Package groovy.contracts
package groovy.contracts
Design-by-contract (DbC) support with compile-time assertion generation.
Stable annotations:
@Requires– method precondition@Ensures– method postcondition; closures may referenceresultandold@Invariant– class invariant, also usable as a loop invariant onfor/while/do-whileloops@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 InterfacesClassDescriptionPackage-level and class-level annotation indicating that the package is enabled for class-invariants, pre- and post-conditions.Specifies a termination measure, either for a loop or for a (recursive) method.Represents a method postcondition.Container annotation for multiple
Ensurespostconditions on the same target.Represents a class-invariant or a loop invariant.Container annotation for multipleInvariantdeclarations on the same type.Declares the frame condition for a method: the set of fields and parameters that the method is allowed to modify.Container for multipleModifiesannotations on the same method.Represents a method precondition.Container annotation for multipleRequirespreconditions on the same target.