Wrap nullable switch selectors in requireNonNull

Proprietary

Wraps a provably-nullable switch selector in java.util.Objects.requireNonNull(...) (statically imported). Switching on a null selector already throws NullPointerException (the selector is dereferenced before any case matches), so inside an annotated scope NullAway flags a nullable selector as an error; requireNonNull throws only where the switch would already fail, so runtime behavior is unchanged. The selector's nullness is resolved by attribution from the nullability model and a path-sensitive flow analysis. A switch that already has a case null label is never touched. The fix never asserts non-null on a value that is genuinely nullable at the site. Idempotent and conservative; only Java sources are modified.

io.moderne.nullability.WrapNullableSwitchSelectorInRequireNonNull

Optional

Comma-separated package prefixes to limit the fix to (matching NullAway's AnnotatedPackages option). When unset, the recipe fixes all packages.

The non-null assertion form to emit at a wrap site. AUTO (the default) emits Preconditions.checkNotNull in a file that already imports Guava's Preconditions, otherwise Objects.requireNonNull. CAST_TO_NON_NULL is explicit-only (it is suppression-like — no runtime throw) and never auto-selected.

mod run . --recipe=io.moderne.nullability.WrapNullableSwitchSelectorInRequireNonNull

Install it once from Recipe actions, then run it on every repository under the current directory. New to the Moderne CLI? Set it up.