Wrap nullable values that are auto-unboxed in requireNonNull
ProprietaryWraps a provably-nullable boxed value (Integer, Long, Boolean, ...) that is used in a primitive context in java.util.Objects.requireNonNull(...) (statically imported). Unboxing such a value is a NullAway error inside an annotated scope, and auto-unboxing a null already throws NullPointerException, so requireNonNull throws exactly where the unboxing already would and runtime behavior is unchanged. The primitive contexts handled are an operand of an arithmetic, relational, or bitwise expression whose other side is a primitive (including ==/!= against a primitive, but not a reference comparison or string concatenation), an argument bound to a primitive callee parameter, an array index, an if/while/do/for/ternary condition, and the return of a primitive-returning method. Nullability is determined from type attribution. The fix only fires where NullAway is active and never asserts non-null on a value that is genuinely nullable at the site. The recipe is idempotent and conservative; only Java sources are modified.
io. moderne. nullability. WrapNullableUnboxingInRequireNonNullOptional
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. WrapNullableUnboxingInRequireNonNullInstall it once from Recipe actions, then run it on every repository under the current directory. New to the Moderne CLI? Set it up.