Skip to content

Commit 665e73a

Browse files
committed
Rename and add Lombok tag
1 parent 4b7fb67 commit 665e73a

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

src/main/java/org/openrewrite/java/migrate/lombok/ConvertGetter.java renamed to src/main/java/org/openrewrite/java/migrate/lombok/UseLombokGetter.java

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
import org.openrewrite.java.JavaTemplate;
2828
import org.openrewrite.java.tree.J;
2929

30+
import java.util.Collections;
3031
import java.util.HashSet;
3132
import java.util.Optional;
3233
import java.util.Set;
@@ -36,7 +37,7 @@
3637

3738
@Value
3839
@EqualsAndHashCode(callSuper = false)
39-
public class ConvertGetter extends Recipe {
40+
public class UseLombokGetter extends Recipe {
4041

4142
@Override
4243
public String getDisplayName() {
@@ -54,6 +55,11 @@ public String getDescription() {
5455
" - Does not offer any of the configuration keys listed in https://projectlombok.org/features/GetterSetter.";
5556
}
5657

58+
@Override
59+
public Set<String> getTags() {
60+
return Collections.singleton("lombok");
61+
}
62+
5763
@Override
5864
public TreeVisitor<?, ExecutionContext> getVisitor() {
5965
return new MethodRemover();
@@ -84,9 +90,7 @@ public J.ClassDeclaration visitClassDeclaration(J.ClassDeclaration classDecl, Ex
8490

8591
@Override
8692
public J.@Nullable MethodDeclaration visitMethodDeclaration(J.MethodDeclaration method, ExecutionContext ctx) {
87-
assert method.getMethodType() != null;
88-
89-
if (LombokUtils.isEffectivelyGetter(method)) {
93+
if (method.getMethodType() != null && LombokUtils.isEffectivelyGetter(method)) {
9094
J.Return return_ = (J.Return) method.getBody().getStatements().get(0);
9195
Variable fieldType = ((J.Identifier) return_.getExpression()).getFieldType();
9296
boolean nameMatch = method.getSimpleName().equals(LombokUtils.deriveGetterMethodName(fieldType));
@@ -106,7 +110,6 @@ private static class Finding {
106110
AccessLevel accessLevel;
107111
}
108112

109-
110113
@Value
111114
@EqualsAndHashCode(callSuper = false)
112115
static class FieldAnnotator extends JavaIsoVisitor<ExecutionContext> {

src/test/java/org/openrewrite/java/migrate/lombok/ConvertGetterTest.java renamed to src/test/java/org/openrewrite/java/migrate/lombok/UseLombokGetterTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,11 @@
2222

2323
import static org.openrewrite.java.Assertions.java;
2424

25-
class ConvertGetterTest implements RewriteTest {
25+
class UseLombokGetterTest implements RewriteTest {
2626

2727
@Override
2828
public void defaults(RecipeSpec spec) {
29-
spec.recipe(new ConvertGetter());
29+
spec.recipe(new UseLombokGetter());
3030
}
3131

3232
@DocumentExample

0 commit comments

Comments
 (0)