groovy / 4.0 / groovy / contracts / invariant.html

[Java] Annotation Type Invariant

  • groovy.contracts.Invariant
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.TYPE)
@Incubating
@ClassInvariant
@AnnotationProcessorImplementation(ClassInvariantAnnotationProcessor.class)
public @interface Invariant

Represents a class-invariant.

The class-invariant defines assertions holding during the entire objects life-time.

Class-invariants are verified at runtime at the following pointcuts:

  • after a constructor call
  • before a method call
  • after a method call

Whenever a class has a parent which itself specifies a class-invariant, that class-invariant expression is combined with the actual class's invariant (by using a logical AND).

Element Summary

Required Element Summary
Type Name and Description
Class value

Inherited Methods Summary

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

Element Detail

public Class value

© 2003-2022 The Apache Software Foundation
Licensed under the Apache license.
https://docs.groovy-lang.org/4.0.0/html/gapi/groovy/contracts/Invariant.html