negated method

  1. @nonVirtual
Spec<T> negated()

Returns the logical negation of this spec.

Returns a new spec that is satisfied when this spec is NOT satisfied. Use this to invert rules without creating separate negation specs. Applying negation twice restores the original satisfaction behavior.

Example:

final notAdult = IsAdult().negated();
final inactive = IsActive().negated();
final notPremium = IsPremium().negated();

Implementation

@nonVirtual
Spec<T> negated() => ~this;