IntentionallyWithoutHashCode

@Target(allowedTargets = [AnnotationTarget.CLASS])
annotation class IntentionallyWithoutHashCode(val reason: ExemptionReason = ExemptionReason.OTHER, val description: String = "")(source)

Acknowledges that the annotated stateful class deliberately uses identity hashing.

The library-api-watchdog compiler plugin warns about publicly visible stateful classes - classes with at least one property backed by a field - that neither declare nor inherit hashCode, because hash-based collections otherwise organize instances by identity instead of meaningful state. Apply this annotation to suppress the warning when identity hashing is intended.

See the check documentation for rationale and examples.

Parameters

reason

why the class deliberately has no hashCode implementation.

description

free-form explanation of the exemption. May be empty only when reason explains the exemption on its own (ExemptionReason.FOR_BACKWARDS_COMPATIBILITY, ExemptionReason.API_DESIGN).

Properties

Link copied to clipboard
Link copied to clipboard