@@ -236,12 +236,12 @@ public DD second() {
236
236
}
237
237
}
238
238
239
- public static final class GenericSpecificityWrapperImpl <E , EE > {
239
+ public static final class GenericSpecificityWrapper0 <E , EE > {
240
240
241
241
private final E first ;
242
242
private final EE second ;
243
243
244
- GenericSpecificityWrapperImpl (E first , EE second ) {
244
+ GenericSpecificityWrapper0 (E first , EE second ) {
245
245
this .first = first ;
246
246
this .second = second ;
247
247
}
@@ -255,8 +255,94 @@ public EE second() {
255
255
}
256
256
257
257
@ JsonCreator (mode = JsonCreator .Mode .DELEGATING )
258
- public static <F > GenericSpecificityWrapperImpl <?, F > fromJson (JsonGenericWrapper <Long , F > val ) {
259
- return new GenericSpecificityWrapperImpl <>(val .first (), val .second ());
258
+ public static <F > GenericSpecificityWrapper0 <?, F > fromJson (JsonGenericWrapper <Long , F > val ) {
259
+ return new GenericSpecificityWrapper0 <>(val .first (), val .second ());
260
+ }
261
+ }
262
+
263
+ public static final class GenericSpecificityWrapper1 <E , EE > {
264
+
265
+ private final E first ;
266
+ private final EE second ;
267
+
268
+ GenericSpecificityWrapper1 (E first , EE second ) {
269
+ this .first = first ;
270
+ this .second = second ;
271
+ }
272
+
273
+ public E first () {
274
+ return first ;
275
+ }
276
+
277
+ public EE second () {
278
+ return second ;
279
+ }
280
+
281
+ @ JsonCreator (mode = JsonCreator .Mode .DELEGATING )
282
+ public static <F extends StringStubSubclass , FF > GenericSpecificityWrapper1 <F , FF > fromJson (JsonGenericWrapper <F , FF > val ) {
283
+ return new GenericSpecificityWrapper1 <>(val .first (), val .second ());
284
+ }
285
+ }
286
+
287
+ public static class StringStub {
288
+ private final String value ;
289
+
290
+ private StringStub (String value ) {
291
+ this .value = value ;
292
+ }
293
+
294
+ @ JsonCreator
295
+ public static StringStub valueOf (String value ) {
296
+ return new StringStub (value );
297
+ }
298
+ }
299
+
300
+ public static class StringStubSubclass extends StringStub {
301
+
302
+ private StringStubSubclass (String value ) {
303
+ super (value );
304
+ }
305
+
306
+ @ JsonCreator
307
+ public static StringStubSubclass valueOf (String value ) {
308
+ return new StringStubSubclass (value );
309
+ }
310
+ }
311
+
312
+ public static final class GenericSpecificityWrapper2 <E , EE > {
313
+
314
+ private final E first ;
315
+ private final EE second ;
316
+
317
+ GenericSpecificityWrapper2 (E first , EE second ) {
318
+ this .first = first ;
319
+ this .second = second ;
320
+ }
321
+
322
+ public E first () {
323
+ return first ;
324
+ }
325
+
326
+ public EE second () {
327
+ return second ;
328
+ }
329
+
330
+ @ JsonCreator (mode = JsonCreator .Mode .DELEGATING )
331
+ public static <F extends Stub <StringStubSubclass >, FF > GenericSpecificityWrapper2 <F , FF > fromJson (JsonGenericWrapper <F , FF > val ) {
332
+ return new GenericSpecificityWrapper2 <>(val .first (), val .second ());
333
+ }
334
+ }
335
+
336
+ public static class Stub <T > {
337
+ private final T value ;
338
+
339
+ private Stub (T value ) {
340
+ this .value = value ;
341
+ }
342
+
343
+ @ JsonCreator
344
+ public static <T > Stub <T > valueOf (T value ) {
345
+ return new Stub <>(value );
260
346
}
261
347
}
262
348
@@ -391,17 +477,40 @@ public void testStaticDelegateDeserialization() throws Exception
391
477
assertEquals ("str" , second );
392
478
}
393
479
394
- public void testStaticDelegateDeserialization_factoryProvidesSpecificity () throws Exception
480
+ public void testStaticDelegateDeserialization_factoryProvidesSpecificity0 () throws Exception
395
481
{
396
- GenericSpecificityWrapperImpl <Object , Account > wrapper = MAPPER .readValue (
482
+ GenericSpecificityWrapper0 <Object , Account > wrapper = MAPPER .readValue (
397
483
"{\" first\" :\" 1\" ,\" second\" :{\" id\" :1,\" name\" :\" name\" }}" ,
398
- new TypeReference <GenericSpecificityWrapperImpl <Object , Account >>() {});
484
+ new TypeReference <GenericSpecificityWrapper0 <Object , Account >>() {});
399
485
Object first = wrapper .first ();
400
486
assertEquals (Long .valueOf (1L ), first );
401
487
Account second = wrapper .second ();
402
488
assertEquals (new Account ("name" , 1L ), second );
403
489
}
404
490
491
+ public void testStaticDelegateDeserialization_factoryProvidesSpecificity1 () throws Exception
492
+ {
493
+ GenericSpecificityWrapper1 <StringStub , Account > wrapper = MAPPER .readValue (
494
+ "{\" first\" :\" 1\" ,\" second\" :{\" id\" :1,\" name\" :\" name\" }}" ,
495
+ new TypeReference <GenericSpecificityWrapper1 <StringStub , Account >>() {});
496
+ StringStub first = wrapper .first ();
497
+ assertEquals ("1" , first .value );
498
+ Account second = wrapper .second ();
499
+ assertEquals (new Account ("name" , 1L ), second );
500
+ }
501
+
502
+ public void testStaticDelegateDeserialization_factoryProvidesSpecificity2 () throws Exception
503
+ {
504
+ GenericSpecificityWrapper2 <Stub <Object >, Account > wrapper = MAPPER .readValue (
505
+ "{\" first\" :\" 1\" ,\" second\" :{\" id\" :1,\" name\" :\" name\" }}" ,
506
+ new TypeReference <GenericSpecificityWrapper2 <Stub <Object >, Account >>() {});
507
+ Stub <Object > first = wrapper .first ();
508
+ StringStub stringStub = (StringStub ) first .value ;
509
+ assertEquals ("1" , stringStub .value );
510
+ Account second = wrapper .second ();
511
+ assertEquals (new Account ("name" , 1L ), second );
512
+ }
513
+
405
514
public void testStaticDelegateDeserialization_wildcardInResult () throws Exception
406
515
{
407
516
WildcardWrapperImpl <Account , Account > wrapper = MAPPER .readValue (
0 commit comments