Skip to content

Commit 912d49d

Browse files
committed
MigrateItemWriterWrite should also convert items.stream()
1 parent c240371 commit 912d49d

File tree

2 files changed

+356
-303
lines changed

2 files changed

+356
-303
lines changed

src/main/java/org/openrewrite/java/spring/batch/MigrateItemWriterWrite.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -121,12 +121,13 @@ public UpdateListMethodInvocations(String parameterName) {
121121
this.parameterName = parameterName;
122122
}
123123

124+
private static final MethodMatcher COLLECTION_MATCHER = new MethodMatcher("java.util.Collection *(..)", true);
124125
private static final MethodMatcher LIST_MATCHER = new MethodMatcher("java.util.List *(..)", true);
125126

126127
@Override
127128
public J.MethodInvocation visitMethodInvocation(J.MethodInvocation method, ExecutionContext ctx) {
128129
J.MethodInvocation mi = super.visitMethodInvocation(method, ctx);
129-
if (LIST_MATCHER.matches(mi) && isParameter(mi.getSelect())) {
130+
if ((COLLECTION_MATCHER.matches(mi) || LIST_MATCHER.matches(mi)) && isParameter(mi.getSelect())) {
130131
assert mi.getPadding().getSelect() != null;
131132
// No need to take care of typing here, since it's going to be printed and parsed on the JavaTemplate later on.
132133
mi = mi.withSelect(newGetItemsMethodInvocation(mi.getPadding().getSelect()));

0 commit comments

Comments
 (0)