Skip to content

Stream API for JsonNullable wrapper - #56

Open
DunkanMcLoud wants to merge 1 commit into
OpenAPITools:masterfrom
DunkanMcLoud:master
Open

Stream API for JsonNullable wrapper#56
DunkanMcLoud wants to merge 1 commit into
OpenAPITools:masterfrom
DunkanMcLoud:master

Conversation

@DunkanMcLoud

Copy link
Copy Markdown

Sometimes it is useful to access DTO's nested data by the means of JDK stream api

@NicklasWallgren

Copy link
Copy Markdown

Any chance of this getting merged?

@DunkanMcLoud

DunkanMcLoud commented Feb 20, 2024

Copy link
Copy Markdown
Author

@NicklasWallgren Hi! As a workaround before merge, you could use lombok's @ExtensionMethod with these methods' implementations. Hope this will help you. Cheers!

@NicklasWallgren

NicklasWallgren commented Feb 20, 2024

Copy link
Copy Markdown

@NicklasWallgren Hi! As a workaround before merge, you could use lombok's @ExtensionMethod with these methods' implementations. Hope this will help you. Cheers!

Thanks for the reply. I've created a fork instead.

@Til7701

Til7701 commented Sep 24, 2025

Copy link
Copy Markdown
Contributor

Thanks for the PR. There is another PR now (#68) which includes some more common methods as well. If that PR is merged, you could recreate this one and add your other methods.

@davidpavlovschi davidpavlovschi left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Triage note: this PR has been superseded on main — since 0.2.8 JsonNullable ships map, flatMap, filter, or, stream and ifPresentOrElse, which covers the core of what this adds. Worse, the two map definitions conflict semantically: the 0.2.8 map applies the mapper whenever isPresent (including an explicit null, so the mapper can see null), while this PR's map guards on isNonNull() and propagates the null state untouched. Changing that now would be a behavioral break for anyone on ≥0.2.8.

What's still genuinely additive here are the null-state helpers that main doesn't have: ofNull(), isNull(), isNonNull(), ifNotNull(). If this were rebased and rescoped to just those, it'd be a reasonable follow-up — with two fixes: (1) the ofMissable javadoc says it returns "UNDEFINED or NULL state" but the implementation (new JsonNullable<>(value, value != null)) actually yields undefined-or-present-non-null — it's Optional.ofNullable semantics, and the name/doc should say so or the method should be dropped; (2) the new test imports junit.framework.TestCase (JUnit 3) — the rest of the suite is on org.junit asserts. Also the change strips the trailing newline from JsonNullable.java.

@DunkanMcLoud if you're still interested, a rebase onto current main scoped to the null-state helpers would make this reviewable; otherwise this can probably be closed as superseded by the 0.2.8 API.

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.

4 participants