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

Any fields present in the constructor do not have to be null #5

Closed
wants to merge 1 commit into from

Conversation

jkschneider
Copy link

Core code unchanged, but added tests to prove this out. Also added more to the test of a class that has a primary and secondary constructor to prove that indeed both could be used by to deserialize.

Updated the docs to strike comment about the requirement for nullability of fields not present in the constructor.

…NOT need to be nullable, flushed out second half of test of class with two constructors, updated docs
@apatrida
Copy link
Member

Don' know how I didn't see pull requests for this long, will check and integrate, thanks

@rocketraman
Copy link

You could also check and document using lateinit for vars. That would change the example from:

JsonProperty("address") var primaryAddress: String = "" // does not have to be nullable

to:

JsonProperty("address") lateinit var primaryAddress: String // does not have to be nullable

@apatrida
Copy link
Member

apatrida commented Jun 4, 2016

@rocketraman that isn't correct, the property is never initialized at all, so lateinit would result in an exception.

@jkschneider it doesn't have to be nullable, it just has to have a default value whatever it is because it is never set by the deserialization.

@apatrida apatrida closed this Jun 4, 2016
apatrida added a commit that referenced this pull request Jun 4, 2016
Pull request #5
Kotlin 1.0.2
Code cleanup
@apatrida
Copy link
Member

apatrida commented Jun 4, 2016

This has been merged into master, 2.5, 2.6, and 2.7 branches

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

3 participants