Move a leading @Nullable to the type-use position
io.moderne.nullability.MoveNullableToTypeUsePositionio.moderne.recipe:rewrite-nullabilityRelocates a leading (declaration-position) JSpecify @Nullable to immediately before the type when modifiers separate them, turning @Nullable private final String f into private final @Nullable String f (and the same for method returns). JSpecify @Nullable is a TYPE_USE annotation, so the type-use position is the precise, conventional placement; the leading form compiles and means the same but reads less clearly. Only the Nullable simple name is moved (declaration-only flavors like @CheckForNull are left alone), the existing annotation is reused, and it only acts when a modifier precedes the type.
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.MoveNullableToTypeUsePositionIf 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