8
8
import com .fasterxml .jackson .databind .deser .impl .PropertyValueBuffer ;
9
9
import com .fasterxml .jackson .databind .introspect .AnnotatedWithParams ;
10
10
import com .fasterxml .jackson .databind .type .LogicalType ;
11
+ import java .math .BigDecimal ;
12
+ import java .math .BigInteger ;
11
13
12
14
/**
13
15
* Class that defines simple API implemented by objects that create value
@@ -137,18 +139,31 @@ public boolean canInstantiate() {
137
139
*/
138
140
public boolean canCreateFromLong () { return false ; }
139
141
142
+ /**
143
+ * Method that can be called to check whether a BigInteger based creator is available
144
+ * to use (to call {@link #createFromBigInteger}). +
145
+ */
146
+ public boolean canCreateFromBigInteger () { return false ; }
147
+
140
148
/**
141
149
* Method that can be called to check whether a double (double / Double) based
142
150
* creator is available to use (to call {@link #createFromDouble}).
143
151
*/
144
152
public boolean canCreateFromDouble () { return false ; }
145
153
154
+ /**
155
+ * Method that can be called to check whether a BigDecimal based creator is available
156
+ * to use (to call {@link #createFromBigDecimal}).
157
+ */
158
+ public boolean canCreateFromBigDecimal () { return false ; }
159
+
146
160
/**
147
161
* Method that can be called to check whether a double (boolean / Boolean) based
148
162
* creator is available to use (to call {@link #createFromDouble}).
149
163
*/
150
164
public boolean canCreateFromBoolean () { return false ; }
151
165
166
+
152
167
/**
153
168
* Method that can be called to check whether a default creator (constructor,
154
169
* or no-arg static factory method)
@@ -263,7 +278,7 @@ public Object createFromObjectWith(DeserializationContext ctxt, Object[] args) t
263
278
* {@link PropertyValueBuffer#getParameter(SettableBeanProperty)} to safely
264
279
* read the present properties only, and to have some other behavior for the
265
280
* missing properties.
266
- *
281
+ *
267
282
* @since 2.8
268
283
*/
269
284
public Object createFromObjectWith (DeserializationContext ctxt ,
@@ -316,12 +331,28 @@ public Object createFromLong(DeserializationContext ctxt, long value) throws IOE
316
331
value );
317
332
}
318
333
334
+ public Object createFromBigInteger (DeserializationContext ctxt , BigInteger value ) throws IOException
335
+ {
336
+ return ctxt .handleMissingInstantiator (getValueClass (),this ,null ,
337
+ "no BigInteger-argument constructor/factory method to deserialize from Number value (%s)" ,
338
+ value
339
+ );
340
+ }
341
+
319
342
public Object createFromDouble (DeserializationContext ctxt , double value ) throws IOException {
320
343
return ctxt .handleMissingInstantiator (getValueClass (), this , null ,
321
344
"no double/Double-argument constructor/factory method to deserialize from Number value (%s)" ,
322
345
value );
323
346
}
324
347
348
+ public Object createFromBigDecimal (DeserializationContext ctxt , BigDecimal value ) throws IOException
349
+ {
350
+ return ctxt .handleMissingInstantiator (getValueClass (),this ,null ,
351
+ "no BigDecimal/double/Double-argument constructor/factory method to deserialize from Number value (%s)" ,
352
+ value
353
+ );
354
+ }
355
+
325
356
public Object createFromBoolean (DeserializationContext ctxt , boolean value ) throws IOException {
326
357
return ctxt .handleMissingInstantiator (getValueClass (), this , null ,
327
358
"no boolean/Boolean-argument constructor/factory method to deserialize from boolean value (%s)" ,
@@ -444,7 +475,7 @@ public Base(Class<?> type) {
444
475
public Base (JavaType type ) {
445
476
_valueType = type .getRawClass ();
446
477
}
447
-
478
+
448
479
@ Override
449
480
public String getValueTypeDesc () {
450
481
return _valueType .getName ();
@@ -468,7 +499,7 @@ public static class Delegating extends ValueInstantiator
468
499
private static final long serialVersionUID = 1L ;
469
500
470
501
protected final ValueInstantiator _delegate ;
471
-
502
+
472
503
protected Delegating (ValueInstantiator delegate ) {
473
504
_delegate = delegate ;
474
505
}
@@ -574,11 +605,21 @@ public Object createFromLong(DeserializationContext ctxt, long value) throws IOE
574
605
return delegate ().createFromLong (ctxt , value );
575
606
}
576
607
608
+ @ Override
609
+ public Object createFromBigInteger (DeserializationContext ctxt , BigInteger value ) throws IOException {
610
+ return delegate ().createFromBigInteger (ctxt , value );
611
+ }
612
+
577
613
@ Override
578
614
public Object createFromDouble (DeserializationContext ctxt , double value ) throws IOException {
579
615
return delegate ().createFromDouble (ctxt , value );
580
616
}
581
617
618
+ @ Override
619
+ public Object createFromBigDecimal (DeserializationContext ctxt , BigDecimal value ) throws IOException {
620
+ return delegate ().createFromBigDecimal (ctxt , value );
621
+ }
622
+
582
623
@ Override
583
624
public Object createFromBoolean (DeserializationContext ctxt , boolean value ) throws IOException {
584
625
return delegate ().createFromBoolean (ctxt , value );
0 commit comments