Replace Stream.collect(Collectors.toUnmodifiableList()) with Stream.toList()

MSAL

Replace Stream.collect(Collectors.toUnmodifiableList()) with Java 16+ Stream.toList(). Also replaces Stream.collect(Collectors.toList()) if convertToList is set to true.

org.openrewrite.java.migrate.util.ReplaceStreamCollectWithToList

Optional

convertToListBoolean

Also replace Stream.collect(Collectors.toList()) with Stream.toList(). BEWARE: Attempts to modify the returned list, result in an UnsupportedOperationException!

mod run . --recipe=org.openrewrite.java.migrate.util.ReplaceStreamCollectWithToList

Install it once from Recipe actions, then run it on every repository under the current directory. New to the Moderne CLI? Set it up.