← All recipes
Moderne licensed

Move a leading @Nullable to the type-use position

Recipe IDio.moderne.nullability.MoveNullableToTypeUsePosition
Artifactio.moderne.recipe:rewrite-nullability

Relocates 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.

Single recipeProprietary

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.MoveNullableToTypeUsePosition

If the recipe isn’t available locally, install it with:

mod config recipes jar install io.moderne.recipe:rewrite-nullability:0.3.1

Data 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