Annotation Interface Contract
Built-in contract annotations are nested under this type so a single
import gives callers access to declarations such as @Contract.Positive
and @Contract.Pattern. Custom composed annotations can be marked with
@Contract and may combine built-in annotations.
Built-in semantic contracts are supported on parameters, methods, fields, and annotation types. Parameter annotations are enforced as preconditions, method annotations are enforced as postconditions on non-void return values, field annotations are metadata for reuse and tools such as Lombok, and annotation-type annotations allow custom composed contracts.
Semantic contracts are null-safe for object values: when a supported value
is null, the contract is skipped and therefore passes. Nullness is
intentionally outside this framework; use dedicated nullness tooling for
required/non-null contracts.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic @interfaceRequires a numeric value to fall within the configured range.static @interfaceMarks a value as confidential for generated violation messages.static @interfaceRequires a numeric value to be less than zero.static @interfaceRequires a numeric value to be greater than or equal to zero.static @interfaceRequires a numeric value to be less than or equal to zero.static @interfaceRequires a character sequence to contain non-whitespace content when non-null.static @interfaceRequires a character sequence, collection, map, or array value to be non-empty when non-null.static @interfaceRequires a character sequence to match the configured regular expression when non-null.static @interfaceRequires a numeric value to be greater than zero.static @interfaceRequires a character sequence, collection, map, or array value size to be in range when non-null.