3
3
import java .util .*;
4
4
5
5
import com .fasterxml .jackson .core .*;
6
-
6
+ import com . fasterxml . jackson . core . json . JsonReadFeature ;
7
7
import com .fasterxml .jackson .databind .cfg .*;
8
8
import com .fasterxml .jackson .databind .deser .DeserializationProblemHandler ;
9
9
import com .fasterxml .jackson .databind .introspect .*;
@@ -498,6 +498,10 @@ public DeserializationConfig withoutFeatures(JsonParser.Feature... features)
498
498
*/
499
499
public DeserializationConfig with (FormatFeature feature )
500
500
{
501
+ // 08-Oct-2018, tatu: Alas, complexity due to newly (2.10) refactored json-features:
502
+ if (feature instanceof JsonReadFeature ) {
503
+ return _withJsonReadFeatures (feature );
504
+ }
501
505
int newSet = _formatReadFeatures | feature .getMask ();
502
506
int newMask = _formatReadFeaturesToChange | feature .getMask ();
503
507
return ((_formatReadFeatures == newSet ) && (_formatReadFeaturesToChange == newMask )) ? this :
@@ -514,6 +518,10 @@ public DeserializationConfig with(FormatFeature feature)
514
518
*/
515
519
public DeserializationConfig withFeatures (FormatFeature ... features )
516
520
{
521
+ // 08-Oct-2018, tatu: Alas, complexity due to newly (2.10) refactored json-features:
522
+ if (features .length > 0 && (features [0 ] instanceof JsonReadFeature )) {
523
+ return _withJsonReadFeatures (features );
524
+ }
517
525
int newSet = _formatReadFeatures ;
518
526
int newMask = _formatReadFeaturesToChange ;
519
527
for (FormatFeature f : features ) {
@@ -535,6 +543,10 @@ public DeserializationConfig withFeatures(FormatFeature... features)
535
543
*/
536
544
public DeserializationConfig without (FormatFeature feature )
537
545
{
546
+ // 08-Oct-2018, tatu: Alas, complexity due to newly (2.10) refactored json-features:
547
+ if (feature instanceof JsonReadFeature ) {
548
+ return _withoutJsonReadFeatures (feature );
549
+ }
538
550
int newSet = _formatReadFeatures & ~feature .getMask ();
539
551
int newMask = _formatReadFeaturesToChange | feature .getMask ();
540
552
return ((_formatReadFeatures == newSet ) && (_formatReadFeaturesToChange == newMask )) ? this :
@@ -551,6 +563,10 @@ public DeserializationConfig without(FormatFeature feature)
551
563
*/
552
564
public DeserializationConfig withoutFeatures (FormatFeature ... features )
553
565
{
566
+ // 08-Oct-2018, tatu: Alas, complexity due to newly (2.10) refactored json-features:
567
+ if (features .length > 0 && (features [0 ] instanceof JsonReadFeature )) {
568
+ return _withoutJsonReadFeatures (features );
569
+ }
554
570
int newSet = _formatReadFeatures ;
555
571
int newMask = _formatReadFeaturesToChange ;
556
572
for (FormatFeature f : features ) {
@@ -562,7 +578,61 @@ public DeserializationConfig withoutFeatures(FormatFeature... features)
562
578
new DeserializationConfig (this , _mapperFeatures , _deserFeatures ,
563
579
_parserFeatures , _parserFeaturesToChange ,
564
580
newSet , newMask );
565
- }
581
+ }
582
+
583
+ // temporary for 2.10
584
+ private DeserializationConfig _withJsonReadFeatures (FormatFeature ... features ) {
585
+ int parserSet = _parserFeatures ;
586
+ int parserMask = _parserFeaturesToChange ;
587
+ int newSet = _formatReadFeatures ;
588
+ int newMask = _formatReadFeaturesToChange ;
589
+ for (FormatFeature f : features ) {
590
+ final int mask = f .getMask ();
591
+ newSet |= mask ;
592
+ newMask |= mask ;
593
+
594
+ if (f instanceof JsonReadFeature ) {
595
+ JsonParser .Feature oldF = ((JsonReadFeature ) f ).mappedFeature ();
596
+ if (oldF != null ) {
597
+ final int pmask = oldF .getMask ();
598
+ parserSet |= pmask ;
599
+ parserMask |= pmask ;
600
+ }
601
+ }
602
+ }
603
+ return ((_formatReadFeatures == newSet ) && (_formatReadFeaturesToChange == newMask )
604
+ && (_parserFeatures == parserSet ) && (_parserFeaturesToChange == parserMask )
605
+ ) ? this :
606
+ new DeserializationConfig (this , _mapperFeatures , _deserFeatures ,
607
+ parserSet , parserMask , newSet , newMask );
608
+ }
609
+
610
+ // temporary for 2.10
611
+ private DeserializationConfig _withoutJsonReadFeatures (FormatFeature ... features ) {
612
+ int parserSet = _parserFeatures ;
613
+ int parserMask = _parserFeaturesToChange ;
614
+ int newSet = _formatReadFeatures ;
615
+ int newMask = _formatReadFeaturesToChange ;
616
+ for (FormatFeature f : features ) {
617
+ final int mask = f .getMask ();
618
+ newSet &= ~mask ;
619
+ newMask |= mask ;
620
+
621
+ if (f instanceof JsonReadFeature ) {
622
+ JsonParser .Feature oldF = ((JsonReadFeature ) f ).mappedFeature ();
623
+ if (oldF != null ) {
624
+ final int pmask = oldF .getMask ();
625
+ parserSet &= ~pmask ;
626
+ parserMask |= pmask ;
627
+ }
628
+ }
629
+ }
630
+ return ((_formatReadFeatures == newSet ) && (_formatReadFeaturesToChange == newMask )
631
+ && (_parserFeatures == parserSet ) && (_parserFeaturesToChange == parserMask )
632
+ ) ? this :
633
+ new DeserializationConfig (this , _mapperFeatures , _deserFeatures ,
634
+ parserSet , parserMask , newSet , newMask );
635
+ }
566
636
567
637
/*
568
638
/**********************************************************
0 commit comments