File tree 1 file changed +5
-8
lines changed
src/main/java/com/fasterxml/jackson/databind/util
1 file changed +5
-8
lines changed Original file line number Diff line number Diff line change @@ -1798,8 +1798,7 @@ public BigInteger getBigIntegerValue() throws IOException
1798
1798
Number n = getNumberValue ();
1799
1799
if (n instanceof BigInteger ) {
1800
1800
return (BigInteger ) n ;
1801
- }
1802
- if (getNumberType () == NumberType .BIG_DECIMAL ) {
1801
+ } else if (n instanceof BigDecimal ) {
1803
1802
return ((BigDecimal ) n ).toBigInteger ();
1804
1803
}
1805
1804
// int/long is simple, but let's also just truncate float/double:
@@ -1812,14 +1811,12 @@ public BigDecimal getDecimalValue() throws IOException
1812
1811
Number n = getNumberValue ();
1813
1812
if (n instanceof BigDecimal ) {
1814
1813
return (BigDecimal ) n ;
1815
- }
1816
- switch (getNumberType ()) {
1817
- case INT :
1818
- case LONG :
1814
+ } else if (n instanceof Integer ) {
1815
+ return BigDecimal .valueOf (n .intValue ());
1816
+ } else if (n instanceof Long ) {
1819
1817
return BigDecimal .valueOf (n .longValue ());
1820
- case BIG_INTEGER :
1818
+ } else if ( n instanceof BigInteger ) {
1821
1819
return new BigDecimal ((BigInteger ) n );
1822
- default :
1823
1820
}
1824
1821
// float or double
1825
1822
return BigDecimal .valueOf (n .doubleValue ());
You can’t perform that action at this time.
0 commit comments