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

Miscellaneous Jackson fixes #270

Merged
merged 4 commits into from May 2, 2019

Conversation

Projects
None yet
2 participants
@kelnos
Copy link
Member

commented May 1, 2019

  • Use unboxed types in parameters and fields where possible
  • Fix setting extended/implemented types (before it was setting all as extends, rather than putting the interfaces on implements, which would generate invalid code).
  • Redesign how polymorphism works (see commit comments for details).

Contributing to Twilio

All third party contributors acknowledge that any contributions they provide will be made under the same open source license that the open source project is provided under.

  • I acknowledge that all my contributions will be made under the project's license.

kelnos added some commits May 1, 2019

Make Jackson polymorphism actually work properly
The old way didn't work because all POJO classes had private
construtors, and so if a base class had properties, there was no way to
properly subclass it.

This is also a bit of a redesign.  Now each class defn in the hierarchy
"owns" its own properties (that is, it has fields for the properties
declared on it).  Child classes also own their own properties, but are
responsible for also taking care of their parents' properties in the
builder, and passing them to superclasses via super() calls in the
constructors.

In the end, this turns out to be a lot more consistent and easier to
reason about.

@kelnos kelnos requested a review from blast-hardcheese May 1, 2019

Convert nulls to empty-optional in Jackson POJO constructors
The Builders ensure that constructor args will never be null, but
Jackson itself might pass null when deserializing from the wire.  Since
we treat optional parameters such that they need not even be present in
the JSON received, we just want an empty optional in these cases and
there's no reason to use requireNonNull(), which will throw an NPE.

@kelnos kelnos force-pushed the kelnos:jackson-fixes branch from 519e07d to 6ee9a37 May 1, 2019

@kelnos kelnos merged commit 311d704 into twilio:master May 2, 2019

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details

@kelnos kelnos deleted the kelnos:jackson-fixes branch May 2, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.