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

Support for optional data class parameters, tests for null encoding in data classes #6

Merged
merged 1 commit into from Jun 22, 2022

Conversation

comp500
Copy link
Contributor

@comp500 comp500 commented Jun 20, 2022

  • Added support for optional data class parameters (default arguments) - allows specifying default values per-field rather than per-type
  • Improved exception thrown when unknown value/target pair is encountered
  • Changed to Any? for parameter decoding to better reflect how decoders can decode to null (though I think it is unchecked at compile-time and doesn't complain with Any)
  • Added tests for the above

…n data classes

Added support for optional data class parameters (default arguments) - allows specifying default values per-field rather than per-type
Improved exception thrown when unknown value/target pair is encountered
Changed to Any? for parameter decoding to better reflect how decoders can decode to null (though I think it is unchecked at compile-time and doesn't complain with Any)
Added tests for the above
@valderman
Copy link
Owner

Very nice!

Just a minor comment: could we use associateWith to build the map passed to callBy´ for readability? That way we get rid of the continue`, we get to use a function with a more specific name instead of general iteration, and we don't need to mutate anything.

@comp500
Copy link
Contributor Author

comp500 commented Jun 20, 2022

Does that allow skipping optional parameters? I guess I could add a filter/mapNotNull before the associateWith but it seems a bit clunky to pass both encodedParameterValue and constructorParameter along after filtering.

@valderman
Copy link
Owner

You're right, that doesn't work; I didn't consider null parameters. Let's go with this as it is!

@valderman valderman merged commit f8f5e8f into valderman:main Jun 22, 2022
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.

None yet

2 participants