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

Change the adapter for Object.class to delegate. #316

Merged
merged 1 commit into from
May 27, 2017

Conversation

swankjesse
Copy link
Collaborator

Previously if we ever had an opaque Object, the content of this object
would always only use the built-in adapters for its members.

This changes the built-in Object adapter to do one layer of type checking
and then to delegate to user-supplied adapters.

The big upside of this is that application code can now change the default
numeric type to use when decoding an untyped object. Typically this will
be used to replace our default of Double with a user-specified numeric type
like BigDecimal.

Copy link
Contributor

@NightlyNexus NightlyNexus left a comment

Choose a reason for hiding this comment

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

Yeah! 👍 LGTM.

* Confirm that the built-in adapter for Object delegates to user-supplied adapters for JSON value
* types like strings.
*/
@Test public void objectAdapterDelegatesStringNamesAndValues() throws Exception {
Copy link
Contributor

Choose a reason for hiding this comment

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

Any reason to put them in MoshiTest instead of ObjectAdapterTest?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yep, that’s better. Fixed.

Previously if we ever had an opaque Object, the content of this object
would always only use the built-in adapters for its members.

This changes the built-in Object adapter to do one layer of type checking
and then to delegate to user-supplied adapters.

The big upside of this is that application code can now change the default
numeric type to use when decoding an untyped object. Typically this will
be used to replace our default of Double with a user-specified numeric type
like BigDecimal.
@swankjesse swankjesse force-pushed the jwilson.0526.delegate_core_adapter branch from ec5f962 to 9e9655b Compare May 27, 2017 03:44
@swankjesse swankjesse merged commit aee3216 into master May 27, 2017
@swankjesse swankjesse deleted the jwilson.0526.delegate_core_adapter branch September 8, 2017 18:30
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