Rename setter methods to fit lombok
io.github.timoa.lombok.NormalizeSetter
Rename methods that are effectively setter to the name lombok would give them.
Limitations:
-
If two methods in a class are effectively the same setter then one’s name will be corrected and the others name will be left as it is.
-
If the correct name for a method is already taken by another method then the name will not be corrected.
-
Method name swaps or circular renaming within a class cannot be performed because the names block each other. E.g.
int getFoo() { return ba; } int getBa() { return foo; }
stays as it is.
Usage
-
Maven POM
-
Maven Command Line
-
Gradle
-
Gradle init script
-
Add the following to your pom.xml file:
pom.xml<project> <build> <plugins> <plugin> <groupId>org.openrewrite.maven</groupId> <artifactId>rewrite-maven-plugin</artifactId> <version>5.42.2</version> <configuration> <activeRecipes> <recipe>io.github.timoa.lombok.NormalizeSetter</recipe> </activeRecipes> </configuration> <dependencies> <dependency> <groupId>io.github.timo-a</groupId> <artifactId>rewrite-recipe-starter</artifactId> <version>0.4.2</version> </dependency> </dependencies> </plugin> </plugins> </build> </project>
-
Run
mvn rewrite:run
to run the recipe.
You will need to have Maven installed on your machine before you can run the following command.
mvn -U org.openrewrite.maven:rewrite-maven-plugin:run -Drewrite.recipeArtifactCoordinates=io.github.timo-a:rewrite-recipe-starter:RELEASE -Drewrite.activeRecipes=io.github.timoa.lombok.NormalizeSetter
-
Add the following to your
build.gradle
file:build.gradleplugins { id("org.openrewrite.rewrite") version("6.25.1") } rewrite { activeRecipe("io.github.timoa.lombok.NormalizeSetter") } repositories { mavenCentral() } dependencies { rewrite("io.github.timo-a:rewrite-recipe-starter:0.4.2") }
-
Run
gradle rewriteRun
to run the recipe.
-
Create a file named
init.gradle
in the root of your project.init.gradleinitscript { repositories { maven { url "https://plugins.gradle.org/m2" } } dependencies { classpath("org.openrewrite:plugin:6.25.1") } } rootProject { plugins.apply(org.openrewrite.gradle.RewritePlugin) dependencies { rewrite("io.github.timo-a:rewrite-recipe-starter:0.4.2") } rewrite { activeRecipe("io.github.timoa.lombok.NormalizeSetter") } afterEvaluate { if (repositories.isEmpty()) { repositories { mavenCentral() } } } }
-
Run
gradle --init-script init.gradle rewriteRun
to run the recipe.