Skip to content

Commit 83287c5

Browse files
1 parent 4f49e0c commit 83287c5

27 files changed

+92
-92
lines changed

src/main/java/org/openrewrite/java/migrate/CastArraysAsListToList.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -63,11 +63,11 @@ public J visitTypeCast(J.TypeCast typeCast, ExecutionContext ctx) {
6363
elementType = ((JavaType.Array) elementType).getElemType();
6464
}
6565

66-
boolean matches = (elementType instanceof JavaType.Class || elementType instanceof JavaType.Parameterized)
67-
&& ((JavaType.FullyQualified) elementType).getOwningClass() == null // does not support inner class now
68-
&& LIST_TO_ARRAY.matches(typeCast.getExpression())
69-
&& typeCast.getExpression() instanceof J.MethodInvocation
70-
&& ARRAYS_AS_LIST.matches(((J.MethodInvocation) typeCast.getExpression()).getSelect());
66+
boolean matches = (elementType instanceof JavaType.Class || elementType instanceof JavaType.Parameterized) &&
67+
((JavaType.FullyQualified) elementType).getOwningClass() == null // does not support inner class now
68+
&& LIST_TO_ARRAY.matches(typeCast.getExpression()) &&
69+
typeCast.getExpression() instanceof J.MethodInvocation &&
70+
ARRAYS_AS_LIST.matches(((J.MethodInvocation) typeCast.getExpression()).getSelect());
7171
if (!matches) {
7272
return typeCast;
7373
}

src/main/java/org/openrewrite/java/migrate/JREThrowableFinalMethods.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,9 @@ public String getDisplayName() {
5656

5757
@Override
5858
public String getDescription() {
59-
return "The recipe renames `getSuppressed()` and `addSuppressed(Throwable exception)` methods in classes "
60-
+ "that extend `java.lang.Throwable` to `myGetSuppressed` and `myAddSuppressed(Throwable)`."
61-
+ "These methods were added to Throwable in Java 7 and are marked final which cannot be overridden.";
59+
return "The recipe renames `getSuppressed()` and `addSuppressed(Throwable exception)` methods in classes " +
60+
"that extend `java.lang.Throwable` to `myGetSuppressed` and `myAddSuppressed(Throwable)`." +
61+
"These methods were added to Throwable in Java 7 and are marked final which cannot be overridden.";
6262
}
6363

6464
@Override

src/main/java/org/openrewrite/java/migrate/MXBeanRule.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,9 +108,9 @@ public J.ClassDeclaration visitClassDeclaration(J.ClassDeclaration classDeclarat
108108
}
109109

110110
List<Modifier> modifiers = new ArrayList<>(cd.getModifiers());
111-
modifiers.removeIf(modifier -> modifier.getType() == Modifier.Type.Private
112-
|| modifier.getType() == Modifier.Type.Protected
113-
|| modifier.getType() == Modifier.Type.Abstract);
111+
modifiers.removeIf(modifier -> modifier.getType() == Modifier.Type.Private ||
112+
modifier.getType() == Modifier.Type.Protected ||
113+
modifier.getType() == Modifier.Type.Abstract);
114114
modifiers.add(new J.Modifier(randomId(), Space.EMPTY, Markers.EMPTY, Modifier.Type.Public, emptyList()));
115115
return maybeAutoFormat(cd, cd.withModifiers(sortModifiers(modifiers)), ctx);
116116
}

src/main/java/org/openrewrite/java/migrate/ReferenceCloneMethod.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,8 @@ public TreeVisitor<?, ExecutionContext> getVisitor() {
5757
@Override
5858
public J visitTypeCast(J.TypeCast typeCast, ExecutionContext ctx) {
5959
J j = super.visitTypeCast(typeCast, ctx);
60-
if (Boolean.TRUE.equals(getCursor().pollNearestMessage(REFERENCE_CLONE_REPLACED))
61-
&& j instanceof J.TypeCast) {
60+
if (Boolean.TRUE.equals(getCursor().pollNearestMessage(REFERENCE_CLONE_REPLACED)) &&
61+
j instanceof J.TypeCast) {
6262
J.TypeCast tc = (J.TypeCast) j;
6363
if (TypeUtils.isOfType(tc.getType(), tc.getExpression().getType())) {
6464
return tc.getExpression();

src/main/java/org/openrewrite/java/migrate/ReplaceComSunAWTUtilitiesMethods.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,8 +119,8 @@ public J visitMethodInvocation(J.MethodInvocation mi, ExecutionContext ctx) {
119119
maybeAddImport("java.awt.GraphicsEnvironment", false);
120120
maybeAddImport("java.awt.Window", false);
121121
maybeAddImport("java.awt.GraphicsDevice.WindowTranslucency", false);
122-
String templateString = "GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().isWindowTranslucencySupported(WindowTranslucency."
123-
+ ((J.FieldAccess) mi.getArguments().get(0)).getSimpleName();
122+
String templateString = "GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().isWindowTranslucencySupported(WindowTranslucency." +
123+
((J.FieldAccess) mi.getArguments().get(0)).getSimpleName();
124124
return JavaTemplate.builder(templateString).
125125
imports("java.awt.GraphicsDevice",
126126
"java.awt.GraphicsEnvironment",

src/main/java/org/openrewrite/java/migrate/UseJavaUtilBase64.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -127,9 +127,9 @@ public J visitNewClass(J.NewClass newClass, ExecutionContext ctx) {
127127
J.NewClass c = (J.NewClass) super.visitNewClass(newClass, ctx);
128128
if (newBase64Encoder.matches(c)) {
129129
// noinspection Convert2MethodRef
130-
JavaTemplate.Builder encoderTemplate = useMimeCoder
131-
? Semantics.expression(this, "getMimeEncoder", () -> Base64.getMimeEncoder())
132-
: Semantics.expression(this, "getEncoder", () -> Base64.getEncoder());
130+
JavaTemplate.Builder encoderTemplate = useMimeCoder ?
131+
Semantics.expression(this, "getMimeEncoder", () -> Base64.getMimeEncoder()) :
132+
Semantics.expression(this, "getEncoder", () -> Base64.getEncoder());
133133
return encoderTemplate
134134
.build()
135135
.apply(updateCursor(c), c.getCoordinates().replace());

src/main/java/org/openrewrite/java/migrate/guava/AbstractNoGuavaImmutableOf.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,8 +170,8 @@ private boolean isParentTypeDownCast(MethodCall immutableMethod) {
170170

171171
private boolean isParentTypeMatched(@Nullable JavaType type) {
172172
JavaType.FullyQualified fq = TypeUtils.asFullyQualified(type);
173-
return TypeUtils.isOfClassType(fq, javaType)
174-
|| TypeUtils.isOfClassType(fq, "java.lang.Object");
173+
return TypeUtils.isOfClassType(fq, javaType) ||
174+
TypeUtils.isOfClassType(fq, "java.lang.Object");
175175
}
176176
});
177177
}

src/main/java/org/openrewrite/java/migrate/guava/NoGuavaCreateTempDir.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,8 @@ public J.MethodInvocation visitMethodInvocation(J.MethodInvocation method, Execu
8686

8787
private boolean isIOExceptionOrException(JavaType.@Nullable FullyQualified fqCatch) {
8888
return fqCatch != null &&
89-
("java.io.IOException".matches(fqCatch.getFullyQualifiedName())
90-
|| "java.lang.Exception".matches(fqCatch.getFullyQualifiedName()));
89+
("java.io.IOException".matches(fqCatch.getFullyQualifiedName()) ||
90+
"java.lang.Exception".matches(fqCatch.getFullyQualifiedName()));
9191
}
9292

9393
private J.MethodInvocation toFilesCreateTempDir(J.MethodInvocation methodInvocation) {

src/main/java/org/openrewrite/java/migrate/io/ReplaceFileInOrOutputStreamFinalizeWithClose.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,8 @@ public J.MethodInvocation visitMethodInvocation(J.MethodInvocation method, Execu
6868
if (METHOD_MATCHER.matches(mi)) {
6969
Expression select = mi.getSelect();
7070
JavaType type = select != null ? select.getType() : getCursor().firstEnclosingOrThrow(J.ClassDeclaration.class).getType();
71-
if (TypeUtils.isAssignableTo(JAVA_IO_FILE_INPUT_STREAM, type)
72-
|| TypeUtils.isAssignableTo(JAVA_IO_FILE_OUTPUT_STREAM, type)) {
71+
if (TypeUtils.isAssignableTo(JAVA_IO_FILE_INPUT_STREAM, type) ||
72+
TypeUtils.isAssignableTo(JAVA_IO_FILE_OUTPUT_STREAM, type)) {
7373
return mi.withName(mi.getName().withSimpleName("close"));
7474
}
7575
}

src/main/java/org/openrewrite/java/migrate/javax/AddColumnAnnotation.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,8 @@ public J.ClassDeclaration visitClassDeclaration(J.ClassDeclaration classDecl, Ex
7373
@Override
7474
public J.VariableDeclarations visitVariableDeclarations(J.VariableDeclarations multiVariable, ExecutionContext ctx) {
7575
// Exit if var does not have @ElementCollection or has @Transient
76-
if (FindAnnotations.find(multiVariable, "@javax.persistence.ElementCollection").isEmpty()
77-
|| !FindAnnotations.find(multiVariable, "@javax.persistence.Transient").isEmpty()) {
76+
if (FindAnnotations.find(multiVariable, "@javax.persistence.ElementCollection").isEmpty() ||
77+
!FindAnnotations.find(multiVariable, "@javax.persistence.Transient").isEmpty()) {
7878
return multiVariable;
7979
}
8080

0 commit comments

Comments
 (0)