Add @Nullable to a functional-interface return type argument fed a null-returning lambda
io.moderne.nullability.AddNullableToFunctionalReturnArgumentio.moderne.recipe:rewrite-nullabilityWhen a null-returning lambda is passed for a functional-interface parameter (such as Function<R, T>) of a method that consumes the produced value in a null-tolerant way, annotates that interface's return type argument @Nullable (Function<R, @Nullable T>) so returning null through the callback is legal under JSpecify/NullAway. This is distinct from widening a pass-through type-parameter bound (handled separately); a de-overlap guard keeps the two from both firing. Only parameters of recognized functional interfaces, on methods declared in the working set, are changed; already-@Nullable and wildcard/raw arguments are left untouched.
Usage
This recipe has no required configuration options. You’ll need the Moderne CLI configured before running the command below.
mod run . --recipe io.moderne.nullability.AddNullableToFunctionalReturnArgumentIf the recipe isn’t available locally, install it with:
mod config recipes jar install io.moderne.recipe:rewrite-nullability:0.3.1Data tables
Structured output this recipe can produce.
- Source files that had resultsSource files that were modified by the recipe run.
org.openrewrite.table.SourcesFileResults - Source files that had search resultsSearch results that were found during the recipe run.
org.openrewrite.table.SearchResults - Source files that errored on a recipeThe details of all errors produced by a recipe run.
org.openrewrite.table.SourcesFileErrors - Recipe performanceStatistics used in analyzing the performance of recipes.
org.openrewrite.table.RecipeRunStats