Use local variable type inference
Recipe ID
org.openrewrite.java.migrate.lang.UseVarArtifact
org.openrewrite.recipe:rewrite-migrate-javaApply local variable type inference (var) for primitives and objects. These recipes can cause unused imports, be advised to run `org.openrewrite.java.RemoveUnusedImports afterwards.
Usage
This recipe has no required configuration options. You’ll need the Moderne CLI configured before running the command below.
mod run . --recipe org.openrewrite.java.migrate.lang.UseVarIf the recipe isn’t available locally, install it with:
mod config recipes jar install org.openrewrite.recipe:rewrite-migrate-java:3.41.0Definition
This recipe runs the following recipes in order.
- Use
varfor reference-typed variablesorg.openrewrite.java.migrate.lang.var.UseVarForObject - Use
varfor variables initialized with type castsorg.openrewrite.java.migrate.lang.var.UseVarForTypeCast - Use
varfor constructor call assignmentsorg.openrewrite.java.migrate.lang.var.UseVarForConstructors - Use
varfor primitive and String variablesorg.openrewrite.java.migrate.lang.var.UseVarForPrimitive - Apply
varto Generic Constructorsorg.openrewrite.java.migrate.lang.var.UseVarForGenericsConstructors - Apply
varto generic method invocationsorg.openrewrite.java.migrate.lang.var.UseVarForGenericMethodInvocations
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