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 JsonNode.asXxx() methods with no defaults to throw exception; add in TreeNode #6

Open
cowtowncoder opened this issue Aug 22, 2017 · 0 comments

Comments

@cowtowncoder
Copy link
Member

Currently various asXxx() methods (like, say, asInt()) return default value (like 0 for int) in case where no conversion is possible. But it would usually be better to instead throw an exception since there are already variants that allow passing of default value to return in invalid case.
Throwing exception instead would allow caller to avoid potentially odd and unhelpful coercions into default value. Given existence of alternatives with defaults no functionality would be removed.

In addition to this change it would make sense to add (demote) these methods in TreeNode, esp. since we can use Java 8 default methods for interfaces.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant