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

Replace !Optional.isPresent() with Optional.isEmpty() on Java 11+ #130

Merged
merged 3 commits into from
Oct 13, 2022
Merged

Replace !Optional.isPresent() with Optional.isEmpty() on Java 11+ #130

merged 3 commits into from
Oct 13, 2022

Conversation

timtebeek
Copy link
Contributor

@timtebeek timtebeek commented Oct 12, 2022

Really quick one, so might be missing some edge cases, but seemed simple enough, and improvement on Java 11 and above.

@timtebeek
Copy link
Contributor Author

While it's unlikely to be used much, we might want to add the inverse here as well; !Optional.isEmpty() -> Optional.isPresent(). What are your thoughts on that?

@pway99
Copy link
Contributor

pway99 commented Oct 13, 2022

while it's unlikely to be used much, we might want to add the inverse here as well; !Optional.isEmpty() -> Optional.isPresent(). What are your thoughts on that?

I agree its probably not that common, although I would not be surprised if it's not all that uncommon ;)

Copy link
Contributor

@pway99 pway99 left a comment

Choose a reason for hiding this comment

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

Looks good @timtebeek.
going to merge this in; adding support for transforming !Optional.isEmpty()' to Optional.isPresent()` can be done with a follow up pr.

@pway99 pway99 merged commit 767d48d into openrewrite:main Oct 13, 2022
@timtebeek timtebeek deleted the optional_isEmpty branch October 13, 2022 22:01
pway99 pushed a commit that referenced this pull request Oct 13, 2022
@tkvangorder tkvangorder added this to the 1.13.0 milestone Oct 21, 2022
@tkvangorder tkvangorder added the recipe Recipe requested label Oct 21, 2022
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.

3 participants