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

DEVEXP-:254 support undefined vs null detection for serialization #35

Conversation

JPPortier
Copy link
Contributor

Java Optional do not enable to detect if a value was explicitly set with a null value or not explicitly` for requests.
So SDK was not able to reset by using the specific null value onto payloads

Adding OptionalValue class having same logic as native Optional but:

  • enabling to set null as an expected value (for native java Optional it is specific value)
  • internal state store information enabling to known if value was explicitly set
  • when converted to DTO: only set values for explicitly initialized values from business logic layer

Then:

  • generated DTO are extended to have knowledge about fields set (internal field xxxDefined and associated getter getXXXDefined)
  • onto serialization: If explicitly set: serialize the value (null or not)

So final payload can:

  • send 'null' value to reset a field
  • do not send the field identifier if not explicitly requested to

Benefits:

  • enable to distinct fields for edition (setting a value vs resetting when sent with null or not sent)
  • reduce request payload received by servers
  • business logic related to required field is delegated to shared mapper and based onto DTO description generated from OAS file (com.sinch.sdk.core.utils.databind.Mapper)

Main points:

Copy link
Contributor

github-actions bot commented Jan 2, 2024

Dependency Review

✅ No vulnerabilities or license issues found.

Scanned Manifest Files

Copy link

@Dovchik Dovchik left a comment

Choose a reason for hiding this comment

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

The PR is massive, I've reviewed key points which looks good.

@JPPortier JPPortier merged commit f119e28 into main Jan 4, 2024
5 checks passed
@JPPortier JPPortier deleted the DEVEXP-254-support-undefined-vs-null-detection-for-serialization branch January 4, 2024 14:25
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.

2 participants