amazon-ion / ion-java

Java streaming parser/serializer for Ion.
https://amazon-ion.github.io/ion-docs/
Apache License 2.0
865 stars 110 forks source link

Clean Up Semantics around java.util.Number-like methods in DOM and Reader APIs. #9

Open almann opened 8 years ago

almann commented 8 years ago

As per discussion, APIs like:

longValue() doubleValue() bigIntegerValue()

Need to be well specified and correctly implemented in Ion Java. java.lang.Number does truncation, but I don't believe this is a useful behavior to follow in Ion Java. Furthermore, if longValue() does not throw, a user cannot determine if a value will fit into a long without materializing a big integer.

Imported from ION-176,IONJAVA-73

hohle commented 8 years ago

I filed an issue several years ago about the #intValue documentation and had a PR describing its behavior. There might be some background there that is is still relevant.

tgregg commented 8 years ago

The last part of the description, "a user cannot determine if a value will fit into a long without materializing a big integer," is related to #76, which I've been working on in some spare time. I'll put out a PR for it soon.

Note that it doesn't get rid of the Number truncation, so most of this issue remains relevant.