Skip to content

Commit

Permalink
Revert some non-intentional changes to UseJavaUtilBase64
Browse files Browse the repository at this point in the history
The lambda which is currently required by the templating annotation processor had been replaced with a method reference. As a result the annotation processor did no longer create a corresponding template class and the test started failing.

Until the template processor supports method references (or something Refaster-like), reverting this part of 95c5eb7 and suppressing these inspections.
  • Loading branch information
knutwannheden committed Mar 6, 2023
1 parent 4924d32 commit 2e7efba
Showing 1 changed file with 5 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import org.openrewrite.java.tree.J;
import org.openrewrite.java.tree.JavaSourceFile;

import java.util.Base64;

public class UseJavaUtilBase64 extends Recipe {
private final String sunPackage;
Expand Down Expand Up @@ -115,15 +116,13 @@ public J visitJavaSourceFile(JavaSourceFile cu, ExecutionContext ctx) {
public J visitNewClass(J.NewClass newClass, ExecutionContext ctx) {
J.NewClass c = (J.NewClass) super.visitNewClass(newClass, ctx);
if (newBase64Encoder.matches(c)) {
//noinspection Convert2MethodRef,ResultOfMethodCallIgnored
return c.withTemplate(
JavaTemplate.builder(this::getCursor, "Base64.getEncoder()")
.imports("java.util.Base64")
.build(),
JavaTemplate.compile(this, "getEncoder",
() -> Base64.getEncoder()).build(),
c.getCoordinates().replace()
);
}

if (newBase64Decoder.matches(newClass)) {
} else if (newBase64Decoder.matches(c)) {
return c.withTemplate(getDecoderTemplate, c.getCoordinates().replace());
}
return c;
Expand Down

0 comments on commit 2e7efba

Please sign in to comment.