Skip to content

Commit 5e715ea

Browse files
authored
avoid getNumberType (#3739)
1 parent 0a4cfc4 commit 5e715ea

File tree

1 file changed

+5
-8
lines changed

1 file changed

+5
-8
lines changed

src/main/java/com/fasterxml/jackson/databind/util/TokenBuffer.java

+5-8
Original file line numberDiff line numberDiff line change
@@ -1798,8 +1798,7 @@ public BigInteger getBigIntegerValue() throws IOException
17981798
Number n = getNumberValue();
17991799
if (n instanceof BigInteger) {
18001800
return (BigInteger) n;
1801-
}
1802-
if (getNumberType() == NumberType.BIG_DECIMAL) {
1801+
} else if (n instanceof BigDecimal) {
18031802
return ((BigDecimal) n).toBigInteger();
18041803
}
18051804
// int/long is simple, but let's also just truncate float/double:
@@ -1812,14 +1811,12 @@ public BigDecimal getDecimalValue() throws IOException
18121811
Number n = getNumberValue();
18131812
if (n instanceof BigDecimal) {
18141813
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) {
18191817
return BigDecimal.valueOf(n.longValue());
1820-
case BIG_INTEGER:
1818+
} else if (n instanceof BigInteger) {
18211819
return new BigDecimal((BigInteger) n);
1822-
default:
18231820
}
18241821
// float or double
18251822
return BigDecimal.valueOf(n.doubleValue());

0 commit comments

Comments
 (0)