@@ -73,12 +73,12 @@ protected JavaVisitor<ExecutionContext> getVisitor() {
7373 .javaParser (() -> JavaParser .fromJavaVersion ().logCompilationWarningsAndErrors (true ).build ())
7474 .build ();
7575
76- final JavaTemplate encodeToString = JavaTemplate .builder (this ::getCursor , "Base64.getEncoder().encodeToString((byte[]) null );" )
76+ final JavaTemplate encodeToString = JavaTemplate .builder (this ::getCursor , "Base64.getEncoder().encodeToString(#{anyArray (byte)} );" )
7777 .imports ("java.util.Base64" )
7878 .doBeforeParseTemplate (System .out ::println )
7979 .build ();
8080
81- final JavaTemplate decode = JavaTemplate .builder (this ::getCursor , "Base64.getDecoder().decode((byte[]) null );" )
81+ final JavaTemplate decode = JavaTemplate .builder (this ::getCursor , "Base64.getDecoder().decode(#{any(String)} );" )
8282 .imports ("java.util.Base64" )
8383 .build ();
8484
@@ -88,14 +88,12 @@ public J visitMethodInvocation(J.MethodInvocation method, ExecutionContext execu
8888 J .MethodInvocation m = (J .MethodInvocation ) super .visitMethodInvocation (method , executionContext );
8989 if (base64EncodeMethod .matches (m ) &&
9090 ("encode" .equals (method .getSimpleName ()) || "encodeBuffer" .equals (method .getSimpleName ()))) {
91- m = m .withTemplate (encodeToString , m .getCoordinates ().replace ());
92- m = m .withArguments (method .getArguments ());
91+ m = m .withTemplate (encodeToString , m .getCoordinates ().replace (), method .getArguments ().get (0 ));
9392 if (method .getSelect () instanceof J .Identifier ) {
9493 m = m .withSelect (method .getSelect ());
9594 }
9695 } else if (base64DecodeBuffer .matches (method )) {
97- m = m .withTemplate (decode , m .getCoordinates ().replace ());
98- m = m .withArguments (method .getArguments ());
96+ m = m .withTemplate (decode , m .getCoordinates ().replace (), method .getArguments ().get (0 ));
9997 if (method .getSelect () instanceof J .Identifier ) {
10098 m = m .withSelect (method .getSelect ());
10199 }
0 commit comments