@@ -789,7 +789,7 @@ public Object convertId(@Nullable Object id) {
789789 @ Nullable
790790 public Object convertId (@ Nullable Object id , Class <?> targetType ) {
791791
792- if (! SpecialTypeTreatment . INSTANCE . isConversionCandidate (id )) {
792+ if (Quirks . skipConversion (id )) {
793793 return id ;
794794 }
795795
@@ -854,8 +854,7 @@ protected boolean isKeyword(String candidate) {
854854 private Object applyFieldTargetTypeHintToValue (Field documentField , @ Nullable Object value ) {
855855
856856 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 )) {
859858 return value ;
860859 }
861860
@@ -1576,20 +1575,19 @@ public MongoConverter getConverter() {
15761575 }
15771576
15781577 /*
1579- * Types that must not be converted
1578+ * Types that must not be converted.
15801579 */
1581- enum SpecialTypeTreatment {
1580+ static class Quirks {
15821581
1583- INSTANCE ;
1582+ private static final Set < Class <?>> types = Set . of ( Pattern . class , BsonRegularExpression . class ) ;
15841583
1585- private final Set < Class <?>> types = Set . of ( Pattern . class , BsonRegularExpression . class );
1584+ static boolean skipConversion ( @ Nullable Object value ) {
15861585
1587- boolean isConversionCandidate (@ Nullable Object value ) {
15881586 if (value == null ) {
15891587 return false ;
15901588 }
15911589
1592- return ! types .contains (value .getClass ());
1590+ return types .contains (value .getClass ());
15931591 }
15941592 }
15951593}
0 commit comments