Skip to content

Commit

Permalink
Remove static JavaTemplate field
Browse files Browse the repository at this point in the history
  • Loading branch information
knutwannheden committed Nov 15, 2024
1 parent 23f9ee7 commit 1464e13
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,6 @@ public TreeVisitor<?, ExecutionContext> getVisitor() {
}

private static class OptionalStreamVisitor extends JavaIsoVisitor<ExecutionContext> {
private static final JavaTemplate template =
JavaTemplate.builder("#{any(java.util.stream.Stream)}.flatMap(Optional::stream)")
.imports("java.util.Optional")
.build();

@Override
public J.MethodInvocation visitMethodInvocation(J.MethodInvocation invocation, ExecutionContext ctx) {
Expand All @@ -77,6 +73,10 @@ public J.MethodInvocation visitMethodInvocation(J.MethodInvocation invocation, E
JRightPadded<Expression> mapSelect = mapInvocation.getPadding().getSelect();
JavaType.Method mapInvocationType = mapInvocation.getMethodType();
Space flatMapComments = getFlatMapComments(mapSelect, filterSelect);
JavaTemplate template =
JavaTemplate.builder("#{any(java.util.stream.Stream)}.flatMap(Optional::stream)")
.imports("java.util.Optional")
.build();
J.MethodInvocation flatMapInvocation = template
.apply(updateCursor(mapInvocation), mapInvocation.getCoordinates().replace(), filterInvocation.getSelect());
return flatMapInvocation.getPadding()
Expand Down

0 comments on commit 1464e13

Please sign in to comment.