Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rewrite Stream.collect(Collectors.toUnmodifiableList()) to Stream.toList() #293

Merged

Conversation

Laurens-W
Copy link
Contributor

What's changed?

Continuation of openrewrite/rewrite-static-analysis#167, which may be declined at this point
Adding a recipe that rewrites Java 11 Stream.collect(Collectors.toUnmodifiableList()) to Java 16 Stream.toList() with an optional toggle to include Stream.collect(Collectors.toList()) so no harm is done initially.

What's your motivation?

I asked on slack if there was an opposing recipe to replacestreamtolistwithcollect, we came to the conclusion that it does not exist but does seem justifiable to have.

Anything in particular you'd like reviewers to focus on?

Anyone you would like to review specifically?

@timtebeek @joanvr

Have you considered any alternatives or workarounds?

Any additional context

Checklist

  • I've added unit tests to cover both positive and negative cases
  • I've added the license header to any new files through ./gradlew licenseFormat
  • I've used the IntelliJ IDEA auto-formatter on affected files

…leList())` and optionally `Stream.collect(Collectors.toList())` to java 16 `Stream.toList()`
@timtebeek timtebeek changed the title Add recipe to rewrite java 11 `Stream.collect(Collectors.toUnmodifiab… Rewrite Stream.collect(Collectors.toUnmodifiableList()) to Stream.toList() Sep 15, 2023
Copy link
Contributor

@timtebeek timtebeek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot @Laurens-W , both for suggesting the recipe and implementing it. I've done a few polishing changes, but otherwise a direct success. :)

@timtebeek timtebeek merged commit 467c10f into openrewrite:main Sep 15, 2023
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
recipe Recipe requested
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

2 participants