* Adds support to `BigDecimal`
Adds to the JsonPrimitive#equals the possibility to support BigDecimal
* Adds test
Adds test to check if the equals work with BigDecimals. Code snippet from issue #904
* Implements review comments
Replaces the `.equals` method with the `compareTo` in the `JsonPrimitive#equals`
Change the ternary operator from `||` to `&&` so we are sure that both are `BigDecimal`
Implements tests
* Changes to follow the google-style-guide
* implements review comment
Co-authored-by: Marcono1234 <Marcono1234@users.noreply.github.com>
* Fixes the `OperatorPrecedence` warn
* Implements code improvements
- Extracts `thisAsDouble` & `otherAsDouble` variables to avoid double functions calls.
- Adds a comment to improve the code readability.
* Implements `BigDecimal` check in the `JsonPrimitive.equals()`
* Formats the code with `spotless:apply`
---------
Co-authored-by: Marcono1234 <Marcono1234@users.noreply.github.com>
* Enable additional Error Prone checks & fix violations
Some of them also enforce additional Google Java Format requirements which
are not handled by google-java-format, such as disallowing wildcard imports.
Not all experimental checks have been listed because some are not applicable,
such as Dependency Injection framework checks, or checks related to Guava's
immutable collections (since Gson's main code does not have a dependency on
Guava).
Other checks have been omitted because they are probably not relevant
(this was a subjective choice), or would require larger refactoring or
would flag issues with the public API, which cannot be changed easily.
* Address review feedback
---------
Co-authored-by: Éamonn McManus <emcmanus@google.com>
* Add settings for kind of newline to use
* Fix amp in javadoc
* Fixing link in javadoc
* Doc: use JSON instead of Json
Co-authored-by: Marcono1234 <Marcono1234@users.noreply.github.com>
* PR Feedback: Objects.requireNonNull
Co-authored-by: Marcono1234 <Marcono1234@users.noreply.github.com>
* PR Feedback: $next-version$, don't hardcode
Co-authored-by: Marcono1234 <Marcono1234@users.noreply.github.com>
* s/testNewlineLF/testNewlineLf/
Co-authored-by: Marcono1234 <Marcono1234@users.noreply.github.com>
* Implement PR feedback
* Round two of review
* Restore copyright year, no reason to update
* Rename OS named enum values to CR and LF
* Add javadoc to NewlineStyle.getValue()
* Implement PR feedback, round 2
* Fix typo
Co-authored-by: Marcono1234 <Marcono1234@users.noreply.github.com>
* No need for line break
Co-authored-by: Marcono1234 <Marcono1234@users.noreply.github.com>
* Shorter, cleaner doc
Co-authored-by: Marcono1234 <Marcono1234@users.noreply.github.com>
* Using a FormattingStyle for pretty print
* Fix Junit4 and Truth after merge from master
* Implement review feedback
* Double backslash in message
---------
Co-authored-by: Marcono1234 <Marcono1234@users.noreply.github.com>
This is probably a break from the past: previous versions of Gson allowed truncating a floating point into a long or int. However, it wasn't consistent in this behavior. It disallowed converting a BigDecimal value into BigInteger, int or long. Refusing to deserialize such values is aligned with fail-fast approach of uncovering bugs.
This avoids needing to parse number if the equivalent object field doesn't exist.
It also avoids the performance penalty of trying to parse it eagerly as a big decimal, float etc.
Integral values (byte, short, integer, long, BigInteger) are now comparable to each other.
Floating point values (float, double, BigDecimal) are now comparable to each other.