Replace Stream Collect by toList

jSparrow Eclipse 4.4.0 & jSparrow Maven 3.11.0

We are happy to announce the jSparrow October release with one new refactoring rule! The new rule makes use of a Stream API extension in Java 16.

Replace Stream Collect by toList

Java 16 iJava 16 introduced Stream.toList() as a shorthand method for converting a Stream into an unmodifiable List. This rule replaces invocations of collect(Collectors.toUnmodifiableList()) by the new method Stream.toList().

For instance, the following code:

is transformed to:

In certain scenarios with immutable context state, collect(Collectors.toList()) is supported, too.


The new rule brings jSparrow to a total of 104 automatic refactoring rules.

Find out more information in the Release Notes for jSparrow Eclipse and jSparrow Maven!

“Programming is the art of telling another human being what one wants the computer to do.” ― Donald E. Knuth

Promotion pop-up

jSparrow 22% off promotion image