@@ -789,7 +789,7 @@ public Object convertId(@Nullable Object id) {
789
789
@ Nullable
790
790
public Object convertId (@ Nullable Object id , Class <?> targetType ) {
791
791
792
- if (! SpecialTypeTreatment . INSTANCE . isConversionCandidate (id )) {
792
+ if (Quirks . skipConversion (id )) {
793
793
return id ;
794
794
}
795
795
@@ -854,8 +854,7 @@ protected boolean isKeyword(String candidate) {
854
854
private Object applyFieldTargetTypeHintToValue (Field documentField , @ Nullable Object value ) {
855
855
856
856
if (value == null || documentField .getProperty () == null || !documentField .getProperty ().hasExplicitWriteTarget ()
857
- || value instanceof Document || value instanceof DBObject
858
- || !SpecialTypeTreatment .INSTANCE .isConversionCandidate (value )) {
857
+ || value instanceof Document || value instanceof DBObject || Quirks .skipConversion (value )) {
859
858
return value ;
860
859
}
861
860
@@ -1576,20 +1575,19 @@ public MongoConverter getConverter() {
1576
1575
}
1577
1576
1578
1577
/*
1579
- * Types that must not be converted
1578
+ * Types that must not be converted.
1580
1579
*/
1581
- enum SpecialTypeTreatment {
1580
+ static class Quirks {
1582
1581
1583
- INSTANCE ;
1582
+ private static final Set < Class <?>> types = Set . of ( Pattern . class , BsonRegularExpression . class ) ;
1584
1583
1585
- private final Set < Class <?>> types = Set . of ( Pattern . class , BsonRegularExpression . class );
1584
+ static boolean skipConversion ( @ Nullable Object value ) {
1586
1585
1587
- boolean isConversionCandidate (@ Nullable Object value ) {
1588
1586
if (value == null ) {
1589
1587
return false ;
1590
1588
}
1591
1589
1592
- return ! types .contains (value .getClass ());
1590
+ return types .contains (value .getClass ());
1593
1591
}
1594
1592
}
1595
1593
}
0 commit comments