Skip to content

Conversation

@ctrimble
Copy link
Contributor

@ctrimble ctrimble commented Aug 21, 2025

This PR adds the streaming methods found on java.util.Optional to the JsonNullable type.

Methods added:

  • isUndefined()
  • orElseGet(Supplier)
  • orElseThrow()
  • orElseThrow(Supplier)
  • ifPresentOrElse(Supplier, Runnable)
  • filter(Predicate)
  • map(Function)
  • flatMap(Function)
  • or(Supplier)
  • stream()

Fixes #7.
Fixes #65.

@ctrimble ctrimble marked this pull request as draft August 21, 2025 10:15
@ctrimble ctrimble force-pushed the feature_streaming-methods branch 3 times, most recently from ae3d143 to 1098000 Compare August 21, 2025 10:37
@ctrimble ctrimble marked this pull request as ready for review August 21, 2025 11:46
@ctrimble ctrimble force-pushed the feature_streaming-methods branch 2 times, most recently from 86946b7 to 50481b5 Compare August 21, 2025 19:58
@ctrimble
Copy link
Contributor Author

@wing328 any thoughts on this or other changes like this that improve the interface on JsonNullable?

@wing328
Copy link
Member

wing328 commented Sep 9, 2025

Thanks for the PR and sorry for late reply,.

We're looking for maintainers: #71

Let me know if you're interesting in maintaining this project. Thank you.

Copy link
Contributor

@Til7701 Til7701 left a comment

Choose a reason for hiding this comment

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

Thanks for the PR. This looks great. There are two small suggestions.

@@ -0,0 +1,421 @@
/*
Copy link
Contributor

Choose a reason for hiding this comment

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

I didn’t notice the copyright in any other files (maybe I missed some).

Are you ok with removing this? I don’t exactly know the difference whether you add this or not though. I assume you’re the copyright holder either way. (…I’m not a lawyer though, so I could be completely wrong.)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I can drop this, if it makes things better for the project.

Copy link
Contributor

Choose a reason for hiding this comment

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

Honestly, I just don't know the implications. @wing328 might be able to provide some guidance?

Copy link
Contributor

@nrayburn-tech nrayburn-tech left a comment

Choose a reason for hiding this comment

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

Mostly minor changes. If you aren't able to get to these, let us know and we can create a new PR with the required changes.

@ctrimble
Copy link
Contributor Author

I think I have time to get to these changes tonight.

@nrayburn-tech
Copy link
Contributor

Sounds good to me.

Can you add the below to the PR description? It will automatically close out some of the other issues when this PR gets merged in.

Fixes #7.
Fixes #65.

@ctrimble
Copy link
Contributor Author

@nrayburn-tech I haven't made the changes yet, but there is now testing that shows exactly where this implementation does not match an equivalent call on Optional. The build will skip comparisons with Optional methods that are not present in the current JDK. Building with Java 17 will show all the issues.

The following all need NullPointerExceptions:

  • filter null predicate on undefined
  • flatMap null predicate on undefined
  • map null mapping on undefined
  • or null supplier on value
  • or null supplier on null

I am going to rework testing of ifPresentOrElse to make sure that is consistent as well.

@ctrimble
Copy link
Contributor Author

@nrayburn-tech I think I have the changes you asked for completed.

Items still open:

  • The license header on StreamingApiTest
  • Should I update the indent to 4 spaces on StreamingApiTest?

I would like to squash this history down and get rebased on master (it looks like the pom.xml cannot merge) before this gets accepted.

@nrayburn-tech
Copy link
Contributor

After you merge in master, you’ll want to update your pom changes to match the existing format.

Use a property for the version.
Put the dependencies within the test region comment.

@ctrimble
Copy link
Contributor Author

@nrayburn-tech the project moved to JUnit 5 while this PR was open. I will have to rework the testing annotations.

@ctrimble ctrimble force-pushed the feature_streaming-methods branch from b2b3080 to fbafe0f Compare September 28, 2025 18:42
@ctrimble
Copy link
Contributor Author

@nrayburn-tech the tests for this are now reworked and history is squashed down. I still need to deal with this license header and possible indentation issue.

Copy link
Contributor

@nrayburn-tech nrayburn-tech left a comment

Choose a reason for hiding this comment

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

I'm not really worried about the license header on the test file or the indent discrepancy. Both are pretty minor right now and can be resolved later in a separate PR if needed. (Tests can be re-written so the copyright doesn't apply, and the code can just be re-formatted if needed.)

found in java.util.Optional.

- isUndefined()
- orElseGet(Supplier)
- orElseThrow()
- orElseThrow(Supplier)
- ifPresentOrElse(Supplier, Runnable)
- filter(Predicate)
- map(Function)
- flatMap(Function)
- or(Supplier)
- stream()
@ctrimble ctrimble force-pushed the feature_streaming-methods branch from d7174b2 to ad0105d Compare October 2, 2025 01:56
@ctrimble
Copy link
Contributor Author

ctrimble commented Oct 2, 2025

@nrayburn-tech history is squashed. I think this is ready to merge.

@nrayburn-tech
Copy link
Contributor

@wing328 can you merge this in when you get some time? Thanks.

@wing328 wing328 merged commit f377eda into OpenAPITools:master Oct 3, 2025
1 check passed
@wing328
Copy link
Member

wing328 commented Oct 3, 2025

Just merged. Thanks for the contribution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add map and flatmap methods New Method isUndefined

4 participants