@@ -64,45 +64,15 @@ private Integer serialiseImpl(Object input, @NotNull Locale locale) {
64
64
65
65
@ NotNull
66
66
private Integer parseValueImpl (@ NotNull Object input , @ NotNull Locale locale ) {
67
- if (!(input instanceof Number )) {
68
- throw new CoercingParseValueException (
69
- i18nMsg (locale , "Int.notInt" , typeName (input ))
70
- );
71
- }
72
-
73
- if (input instanceof Integer ) {
74
- return (Integer ) input ;
75
- }
67
+ Integer result = convertImpl (input );
76
68
77
- BigInteger result = convertParseValueImpl (input );
78
69
if (result == null ) {
79
70
throw new CoercingParseValueException (
80
71
i18nMsg (locale , "Int.notInt" , typeName (input ))
81
72
);
82
73
}
83
74
84
- if (result .compareTo (INT_MIN ) < 0 || result .compareTo (INT_MAX ) > 0 ) {
85
- throw new CoercingParseValueException (
86
- i18nMsg (locale , "Int.outsideRange" , result .toString ())
87
- );
88
- }
89
- return result .intValueExact ();
90
- }
91
-
92
- private BigInteger convertParseValueImpl (Object input ) {
93
- BigDecimal value ;
94
- try {
95
- value = new BigDecimal (input .toString ());
96
- } catch (NumberFormatException e ) {
97
- return null ;
98
- }
99
-
100
- try {
101
- return value .toBigIntegerExact ();
102
- } catch (ArithmeticException e ) {
103
- // Exception if number has non-zero fractional part
104
- return null ;
105
- }
75
+ return result ;
106
76
}
107
77
108
78
private static int parseLiteralImpl (Object input , @ NotNull Locale locale ) {
0 commit comments