Skip to content

Commit ba0b311

Browse files
timtebeekTeamModerne
authored andcommitted
Replace getDisplayName() and getDescription() methods with fields
Use this link to re-run the recipe: https://app.moderne.io/recipes/org.openrewrite.java.recipes.UseDisplayNameAndDescriptionFields?organizationId=QUxML01vZGVybmUvTW9kZXJuZSArIE9wZW5SZXdyaXRl Co-authored-by: Moderne <team@moderne.io>
1 parent e0db1c7 commit ba0b311

27 files changed

+54
-219
lines changed

src/main/java/org/openrewrite/gradle/spring/AddSpringDependencyManagementPlugin.java

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -34,17 +34,11 @@
3434
@EqualsAndHashCode(callSuper = false)
3535
@Value
3636
public class AddSpringDependencyManagementPlugin extends Recipe {
37-
@Override
38-
public String getDisplayName() {
39-
return "Add `io.spring.dependency-management` plugin, if in use";
40-
}
37+
String displayName = "Add `io.spring.dependency-management` plugin, if in use";
4138

42-
@Override
43-
public String getDescription() {
44-
return "Prior to Spring Boot 2.0 the dependency management plugin was applied automatically as part of the overall spring boot plugin. " +
39+
String description = "Prior to Spring Boot 2.0 the dependency management plugin was applied automatically as part of the overall spring boot plugin. " +
4540
"Afterwards the dependency-management plugin must be applied explicitly, or Gradle's `platform()` feature may be used instead. " +
4641
"This recipe makes usage of io-spring.dependency-management explicit in anticipation of upgrade to Spring Boot 2.0 or later.";
47-
}
4842

4943
@Override
5044
public TreeVisitor<?, ExecutionContext> getVisitor() {

src/main/java/org/openrewrite/java/spring/AddSpringProperty.java

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -68,15 +68,9 @@ public class AddSpringProperty extends Recipe {
6868
@Nullable
6969
List<String> pathExpressions;
7070

71-
@Override
72-
public String getDisplayName() {
73-
return "Add a spring configuration property";
74-
}
71+
String displayName = "Add a spring configuration property";
7572

76-
@Override
77-
public String getDescription() {
78-
return "Add a spring configuration property to a configuration file if it does not already exist in that file.";
79-
}
73+
String description = "Add a spring configuration property to a configuration file if it does not already exist in that file.";
8074

8175
@Override
8276
public TreeVisitor<?, ExecutionContext> getVisitor() {

src/main/java/org/openrewrite/java/spring/ChangeMethodParameter.java

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -68,15 +68,9 @@ public String getInstanceNameSuffix() {
6868
return String.format("`%s` in methods `%s`", parameterType, methodPattern);
6969
}
7070

71-
@Override
72-
public String getDisplayName() {
73-
return "Change parameter type for a method declaration";
74-
}
71+
String displayName = "Change parameter type for a method declaration";
7572

76-
@Override
77-
public String getDescription() {
78-
return "Change parameter type for a method declaration, identified by a method pattern.";
79-
}
73+
String description = "Change parameter type for a method declaration, identified by a method pattern.";
8074

8175
@Override
8276
public TreeVisitor<?, ExecutionContext> getVisitor() {

src/main/java/org/openrewrite/java/spring/ChangeSpringPropertyKey.java

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -46,15 +46,9 @@
4646
@Value
4747
public class ChangeSpringPropertyKey extends Recipe {
4848

49-
@Override
50-
public String getDisplayName() {
51-
return "Change the key of a Spring application property";
52-
}
49+
String displayName = "Change the key of a Spring application property";
5350

54-
@Override
55-
public String getDescription() {
56-
return "Change Spring application property keys existing in either Properties or YAML files, and in `@Value`, `@ConditionalOnProperty` or `@SpringBootTest` annotations.";
57-
}
51+
String description = "Change Spring application property keys existing in either Properties or YAML files, and in `@Value`, `@ConditionalOnProperty` or `@SpringBootTest` annotations.";
5852

5953
@Option(displayName = "Old property key",
6054
description = "The property key to rename.",

src/main/java/org/openrewrite/java/spring/ChangeSpringPropertyValue.java

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,9 @@
2929
@Value
3030
public class ChangeSpringPropertyValue extends Recipe {
3131

32-
@Override
33-
public String getDisplayName() {
34-
return "Change the value of a spring application property";
35-
}
32+
String displayName = "Change the value of a spring application property";
3633

37-
@Override
38-
public String getDescription() {
39-
return "Change spring application property values existing in either Properties or Yaml files.";
40-
}
34+
String description = "Change spring application property values existing in either Properties or Yaml files.";
4135

4236
@Option(displayName = "Property key",
4337
description = "The name of the property key whose value is to be changed.",

src/main/java/org/openrewrite/java/spring/CommentOutSpringPropertyKey.java

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,9 @@
2727
@Value
2828
public class CommentOutSpringPropertyKey extends Recipe {
2929

30-
@Override
31-
public String getDisplayName() {
32-
return "Comment out Spring properties";
33-
}
30+
String displayName = "Comment out Spring properties";
3431

35-
@Override
36-
public String getDescription() {
37-
return "Add comment to specified Spring properties, and comment out the property.";
38-
}
32+
String description = "Add comment to specified Spring properties, and comment out the property.";
3933

4034
@Option(displayName = "Property key",
4135
description = "The name of the property key to comment out.",

src/main/java/org/openrewrite/java/spring/DeleteSpringProperty.java

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -36,15 +36,9 @@ public class DeleteSpringProperty extends Recipe {
3636
example = "management.endpoint.configprops.*")
3737
String propertyKey;
3838

39-
@Override
40-
public String getDisplayName() {
41-
return "Delete a spring configuration property";
42-
}
39+
String displayName = "Delete a spring configuration property";
4340

44-
@Override
45-
public String getDescription() {
46-
return "Delete a spring configuration property from any configuration file that contains a matching key.";
47-
}
41+
String description = "Delete a spring configuration property from any configuration file that contains a matching key.";
4842

4943
@Override
5044
public TreeVisitor<?, ExecutionContext> getVisitor() {

src/main/java/org/openrewrite/java/spring/ExpandProperties.java

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -43,15 +43,9 @@ public class ExpandProperties extends Recipe {
4343
@Nullable
4444
private String sourceFileMask;
4545

46-
@Override
47-
public String getDisplayName() {
48-
return "Expand Spring YAML properties";
49-
}
46+
String displayName = "Expand Spring YAML properties";
5047

51-
@Override
52-
public String getDescription() {
53-
return "Expand YAML properties to not use the dot syntax shortcut.";
54-
}
48+
String description = "Expand YAML properties to not use the dot syntax shortcut.";
5549

5650
@Override
5751
public TreeVisitor<?, ExecutionContext> getVisitor() {

src/main/java/org/openrewrite/java/spring/RenameBean.java

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -69,15 +69,9 @@ public class RenameBean extends ScanningRecipe<List<TreeVisitor<?, ExecutionCont
6969
add(FQN_COMPONENT);
7070
}};
7171

72-
@Override
73-
public String getDisplayName() {
74-
return "Rename bean";
75-
}
72+
String displayName = "Rename bean";
7673

77-
@Override
78-
public String getDescription() {
79-
return "Renames a Spring bean, both declaration and references.";
80-
}
74+
String description = "Renames a Spring bean, both declaration and references.";
8175

8276
@Override
8377
public List<TreeVisitor<?, ExecutionContext>> getInitialValue(ExecutionContext ctx) {

src/main/java/org/openrewrite/java/spring/SeparateApplicationPropertiesByProfile.java

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -39,15 +39,9 @@
3939
@EqualsAndHashCode(callSuper = false)
4040
public class SeparateApplicationPropertiesByProfile extends ScanningRecipe<SeparateApplicationPropertiesByProfile.Accumulator> {
4141

42-
@Override
43-
public String getDisplayName() {
44-
return "Separate `application.properties` by profile";
45-
}
42+
String displayName = "Separate `application.properties` by profile";
4643

47-
@Override
48-
public String getDescription() {
49-
return "Separating `application.properties` into separate files based on profiles.";
50-
}
44+
String description = "Separating `application.properties` into separate files based on profiles.";
5145

5246
@Override
5347
public Accumulator getInitialValue(ExecutionContext ctx) {

0 commit comments

Comments
 (0)