Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,9 @@ public class AddMissingMethodImplementation extends Recipe {
example = "public String hello() { return \\\"Hello from #{}!\\\"; }")
String methodTemplateString;

@Override
public String getDisplayName() {
return "Adds missing method implementations";
}
String displayName = "Adds missing method implementations";

@Override
public String getDescription() {
return "Check for missing methods required by interfaces and adds them.";
}
String description = "Check for missing methods required by interfaces and adds them.";

@Override
public TreeVisitor<?, ExecutionContext> getVisitor() {
Expand Down
10 changes: 2 additions & 8 deletions src/main/java/org/openrewrite/java/migrate/BeanDiscovery.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,9 @@ public class BeanDiscovery extends Recipe {
private static final XPathMatcher BEANS_MATCHER = new XPathMatcher("/beans");
private static final Pattern VERSION_PATTERN = Pattern.compile("_([^\\/\\.]+)\\.xsd");

@Override
public String getDisplayName() {
return "Behavior change to bean discovery in modules with `beans.xml` file with no version specified";
}
String displayName = "Behavior change to bean discovery in modules with `beans.xml` file with no version specified";

@Override
public String getDescription() {
return "Alters beans with missing version attribute to include this attribute as well as the bean-discovery-mode=\"all\" attribute to maintain an explicit bean archive.";
}
String description = "Alters beans with missing version attribute to include this attribute as well as the bean-discovery-mode=\"all\" attribute to maintain an explicit bean archive.";

@Override
public TreeVisitor<?, ExecutionContext> getVisitor() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,9 @@ public class BeansXmlNamespace extends Recipe {
private static final String SUN_SCHEMA_LOCATION = "http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/beans_1_0.xsd";
private static final String JCP_SCHEMA_LOCATION = "http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/beans_1_1.xsd";

@Override
public String getDisplayName() {
return "Change `beans.xml` `schemaLocation` to match XML namespace";
}
String displayName = "Change `beans.xml` `schemaLocation` to match XML namespace";

@Override
public String getDescription() {
return "Set the `schemaLocation` that corresponds to the `xmlns` set in `beans.xml` files.";
}
String description = "Set the `schemaLocation` that corresponds to the `xmlns` set in `beans.xml` files.";

@Override
public TreeVisitor<?, ExecutionContext> getVisitor() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,9 @@ public class ChangeMethodInvocationReturnType extends Recipe {
example = "long")
String newReturnType;

@Override
public String getDisplayName() {
return "Change method invocation return type";
}
String displayName = "Change method invocation return type";

@Override
public String getDescription() {
return "Changes the return type of a method invocation.";
}
String description = "Changes the return type of a method invocation.";

@Override
public List<Recipe> getRecipeList() {
Expand Down
10 changes: 2 additions & 8 deletions src/main/java/org/openrewrite/java/migrate/DontOverfetchDto.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,16 +50,10 @@ public class DontOverfetchDto extends Recipe {
example = "name")
String dtoDataElement;

@Override
public String getDisplayName() {
return "Replace DTO method parameters with data elements";
}
String displayName = "Replace DTO method parameters with data elements";

@Override
public String getDescription() {
return "Replace method parameters that have DTOs with their " +
String description = "Replace method parameters that have DTOs with their " +
"data elements when only the specified data element is used.";
}

@Override
public TreeVisitor<?, ExecutionContext> getVisitor() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,9 @@
@EqualsAndHashCode(callSuper = false)
@Value
public class JpaCacheProperties extends Recipe {
@Override
public String getDisplayName() {
return "Disable the persistence unit second-level cache";
}
String displayName = "Disable the persistence unit second-level cache";

@Override
public String getDescription() {
return "Sets an explicit value for the shared cache mode.";
}
String description = "Sets an explicit value for the shared cache mode.";

@Override
public TreeVisitor<?, ExecutionContext> getVisitor() {
Expand Down
10 changes: 2 additions & 8 deletions src/main/java/org/openrewrite/java/migrate/MXBeanRule.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,9 @@
@Value
public class MXBeanRule extends Recipe {

@Override
public String getDisplayName() {
return "MBean and MXBean interfaces must be public";
}
String displayName = "MBean and MXBean interfaces must be public";

@Override
public String getDescription() {
return "Sets visibility of MBean and MXBean interfaces to public.";
}
String description = "Sets visibility of MBean and MXBean interfaces to public.";

@Override
public TreeVisitor<?, ExecutionContext> getVisitor() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,17 +35,11 @@
public class ReferenceCloneMethod extends Recipe {
private static final MethodMatcher REFERENCE_CLONE = new MethodMatcher("java.lang.ref.Reference clone()", true);

@Override
public String getDisplayName() {
return "Replace `java.lang.ref.Reference.clone()` with constructor call";
}
String displayName = "Replace `java.lang.ref.Reference.clone()` with constructor call";

@Override
public String getDescription() {
return "The recipe replaces any clone calls that may resolve to a `java.lang.ref.Reference.clone()` " +
String description = "The recipe replaces any clone calls that may resolve to a `java.lang.ref.Reference.clone()` " +
"or any of its known subclasses: `java.lang.ref.PhantomReference`, `java.lang.ref.SoftReference`, and `java.lang.ref.WeakReference` " +
"with a constructor call passing in the referent and reference queue as parameters.";
}

@Override
public TreeVisitor<?, ExecutionContext> getVisitor() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,17 +52,11 @@ public ReplaceAWTGetPeerMethod() {
lightweightPeerFQCN = "java.awt.peer.LightweightPeer";
}

@Override
public String getDisplayName() {
return "Replace AWT `getPeer()` method";
}
String displayName = "Replace AWT `getPeer()` method";

@Override
public String getDescription() {
return "This recipe replaces the use of `getPeer()` method in `java.awt.*` classes. " +
String description = "This recipe replaces the use of `getPeer()` method in `java.awt.*` classes. " +
"`component.getPeer() != null` is replaced with `component.isDisplayable()` and " +
"`component.getPeer() instanceof LightweightPeer` is replaced with `component.isLightweight()`.";
}

@Override
public TreeVisitor<?, ExecutionContext> getVisitor() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,17 +87,11 @@ public ReplaceComSunAWTUtilitiesMethods() {
setWindowOpacityPattern = "com.sun.awt.AWTUtilities setWindowOpacity(java.awt.Window, float)";
}

@Override
public String getDisplayName() {
return "Replace `com.sun.awt.AWTUtilities` static method invocations";
}
String displayName = "Replace `com.sun.awt.AWTUtilities` static method invocations";

@Override
public String getDescription() {
return "This recipe replaces several static calls in `com.sun.awt.AWTUtilities` with the JavaSE 11 equivalent. " +
String description = "This recipe replaces several static calls in `com.sun.awt.AWTUtilities` with the JavaSE 11 equivalent. " +
"The methods replaced are `AWTUtilities.isTranslucencySupported()`, `AWTUtilities.setWindowOpacity()`, `AWTUtilities.getWindowOpacity()`, " +
"`AWTUtilities.getWindowShape()`, `AWTUtilities.isWindowOpaque()`, `AWTUtilities.isTranslucencyCapable()` and `AWTUtilities.setComponentMixingCutoutShape()`.";
}

@Override
public TreeVisitor<?, ExecutionContext> getVisitor() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,16 +53,10 @@ public ReplaceLocalizedStreamMethods(
"java.lang.Runtime getLocalizedOutputStream(java.io.OutputStream)" : localizedOutputStreamMethodMatcher;
}

@Override
public String getDisplayName() {
return "Replace `getLocalizedInputStream` and `getLocalizedOutputStream` with direct assignment";
}
String displayName = "Replace `getLocalizedInputStream` and `getLocalizedOutputStream` with direct assignment";

@Override
public String getDescription() {
return "Replaces `Runtime.getLocalizedInputStream(InputStream)` and `Runtime.getLocalizedOutputStream(OutputStream)` with their direct arguments. " +
String description = "Replaces `Runtime.getLocalizedInputStream(InputStream)` and `Runtime.getLocalizedOutputStream(OutputStream)` with their direct arguments. " +
"This modification is made because the previous implementation of `getLocalizedInputStream` and `getLocalizedOutputStream` merely returned the arguments provided.";
}

@Override
public TreeVisitor<?, ExecutionContext> getVisitor() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,15 +53,9 @@ public ReplaceStringLiteralValue(@JsonProperty("oldStringValue") @NonNull String
this.newLiteralValue = newStringValue;
}

@Override
public String getDisplayName() {
return "Replace `String` literal";
}
String displayName = "Replace `String` literal";

@Override
public String getDescription() {
return "Replace the value of a complete `String` literal.";
}
String description = "Replace the value of a complete `String` literal.";

@Override
public List<Recipe> getRecipeList() {
Expand Down
11 changes: 2 additions & 9 deletions src/main/java/org/openrewrite/java/migrate/UpdateSdkMan.java
Original file line number Diff line number Diff line change
Expand Up @@ -56,19 +56,12 @@ public class UpdateSdkMan extends Recipe {
@Nullable
String newDistribution;

@Override
public String getDisplayName() {
return "Update SDKMan Java version";
}
String displayName = "Update SDKMan Java version";

@Override
public String getDescription() {
//language=markdown
return "Update the SDKMAN JDK version in the `.sdkmanrc` file. Given a major release (e.g., 17), the recipe " +
String description = "Update the SDKMAN JDK version in the `.sdkmanrc` file. Given a major release (e.g., 17), the recipe " +
"will update the current distribution to the current default SDKMAN version of the specified major " +
"release. The distribution option can be used to specify a specific JVM distribution. " +
"Note that these must correspond to valid SDKMAN distributions.";
}

@Override
public Validated<Object> validate(ExecutionContext ctx) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,18 +40,12 @@ public class UpgradeJavaVersion extends Recipe {
example = "11")
Integer version;

@Override
public String getDisplayName() {
return "Upgrade Java version";
}
String displayName = "Upgrade Java version";

@Override
public String getDescription() {
return "Upgrade build plugin configuration to use the specified Java version. " +
String description = "Upgrade build plugin configuration to use the specified Java version. " +
"This recipe changes `java.toolchain.languageVersion` in `build.gradle(.kts)` of gradle projects, " +
"or maven-compiler-plugin target version and related settings. " +
"Will not downgrade if the version is newer than the specified version.";
}

@Override
public List<Recipe> getRecipeList() {
Expand Down
10 changes: 2 additions & 8 deletions src/main/java/org/openrewrite/java/migrate/UseTabsOrSpaces.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,16 +36,10 @@ public class UseTabsOrSpaces extends Recipe {
description = "Whether to use tabs for indentation.")
boolean useTabs;

@Override
public String getDisplayName() {
return "Force indentation to either tabs or spaces";
}
String displayName = "Force indentation to either tabs or spaces";

@Override
public String getDescription() {
return "This is useful for one-off migrations of a codebase that has mixed indentation styles, while " +
String description = "This is useful for one-off migrations of a codebase that has mixed indentation styles, while " +
"preserving all other auto-detected formatting rules.";
}

@Override
public TreeVisitor<?, ExecutionContext> getVisitor() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,9 @@ public class PreferJavaUtilOptionalOrSupplier extends Recipe {

static final MethodMatcher METHOD_MATCHER = new MethodMatcher("com.google.common.base.Optional or(com.google.common.base.Optional)");

@Override
public String getDisplayName() {
return "Prefer `java.util.Optional#or(Supplier<T extends java.util.Optional<T>>)`";
}
String displayName = "Prefer `java.util.Optional#or(Supplier<T extends java.util.Optional<T>>)`";

@Override
public String getDescription() {
return "Prefer `java.util.Optional#or(Supplier<T extends java.util.Optional<T>>)` over `com.google.common.base.Optional#or(com.google.common.base.Optional).";
}
String description = "Prefer `java.util.Optional#or(Supplier<T extends java.util.Optional<T>>)` over `com.google.common.base.Optional#or(com.google.common.base.Optional).";

@Override
public Set<String> getTags() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/
package org.openrewrite.java.migrate.io;

import lombok.EqualsAndHashCode;
import lombok.Value;
import org.jspecify.annotations.Nullable;
import org.openrewrite.*;
Expand All @@ -32,24 +33,20 @@

import static java.util.Collections.emptyList;

@Value
@EqualsAndHashCode(callSuper = false)
public class AddInputStreamBulkReadMethod extends Recipe {

private static final String MARKER_MESSAGE = "Missing bulk read method may cause significant performance degradation";
private static final String JAVA_IO_INPUT_STREAM = "java.io.InputStream";

@Override
public String getDisplayName() {
return "Add bulk read method to `InputStream` implementations";
}
String displayName = "Add bulk read method to `InputStream` implementations";

@Override
public String getDescription() {
return "Adds a `read(byte[], int, int)` method to `InputStream` subclasses that only override the single-byte " +
String description = "Adds a `read(byte[], int, int)` method to `InputStream` subclasses that only override the single-byte " +
"`read()` method. Java's default `InputStream.read(byte[], int, int)` implementation calls the " +
"single-byte `read()` method in a loop, which can cause severe performance degradation (up to 350x " +
"slower) for bulk reads. This recipe detects `InputStream` implementations that delegate to another " +
"stream and adds the missing bulk read method to delegate bulk reads as well.";
}

@Override
public TreeVisitor<?, ExecutionContext> getVisitor() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,9 @@ public class ReplaceFileInOrOutputStreamFinalizeWithClose extends Recipe {
private static final String JAVA_IO_FILE_OUTPUT_STREAM = "java.io.FileOutputStream";
private static final MethodMatcher METHOD_MATCHER = new MethodMatcher("java.lang.Object finalize()");

@Override
public String getDisplayName() {
return "Replace invocations of `finalize()` on `FileInputStream` and `FileOutputStream` with `close()`";
}
String displayName = "Replace invocations of `finalize()` on `FileInputStream` and `FileOutputStream` with `close()`";

@Override
public String getDescription() {
return "Replace invocations of the deprecated `finalize()` method on `FileInputStream` and `FileOutputStream` with `close()`.";
}
String description = "Replace invocations of the deprecated `finalize()` method on `FileInputStream` and `FileOutputStream` with `close()`.";

@Override
public Set<String> getTags() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
*/
package org.openrewrite.java.migrate.jakarta;

import lombok.EqualsAndHashCode;
import lombok.Value;
import org.openrewrite.ExecutionContext;
import org.openrewrite.ScanningRecipe;
Expand All @@ -28,17 +29,13 @@
import java.util.HashSet;
import java.util.Set;

@Value
@EqualsAndHashCode(callSuper = false)
public class HasNoJakartaAnnotations extends ScanningRecipe<HasNoJakartaAnnotations.Accumulator> {
@Override
public String getDisplayName() {
return "Project has no Jakarta annotations";
}
String displayName = "Project has no Jakarta annotations";

@Override
public String getDescription() {
return "Mark all source as found per `JavaProject` where no Jakarta annotations are found. " +
String description = "Mark all source as found per `JavaProject` where no Jakarta annotations are found. " +
"This is useful mostly as a precondition for recipes that require Jakarta annotations to be present.";
}

@Value
public static class Accumulator {
Expand Down
Loading