@@ -816,7 +816,7 @@ public Object convertId(@Nullable Object id) {
816
816
@ Nullable
817
817
public Object convertId (@ Nullable Object id , Class <?> targetType ) {
818
818
819
- if (! SpecialTypeTreatment . INSTANCE . isConversionCandidate (id )) {
819
+ if (Quirks . skipConversion (id )) {
820
820
return id ;
821
821
}
822
822
@@ -881,8 +881,7 @@ protected boolean isKeyword(String candidate) {
881
881
private Object applyFieldTargetTypeHintToValue (Field documentField , @ Nullable Object value ) {
882
882
883
883
if (value == null || documentField .getProperty () == null || !documentField .getProperty ().hasExplicitWriteTarget ()
884
- || value instanceof Document || value instanceof DBObject
885
- || !SpecialTypeTreatment .INSTANCE .isConversionCandidate (value )) {
884
+ || value instanceof Document || value instanceof DBObject || Quirks .skipConversion (value )) {
886
885
return value ;
887
886
}
888
887
@@ -1611,20 +1610,19 @@ public <T> T getPropertyValue(MongoPersistentProperty property) {
1611
1610
}
1612
1611
1613
1612
/*
1614
- * Types that must not be converted
1613
+ * Types that must not be converted.
1615
1614
*/
1616
- enum SpecialTypeTreatment {
1615
+ static class Quirks {
1617
1616
1618
- INSTANCE ;
1617
+ private static final Set < Class <?>> types = Set . of ( Pattern . class , BsonRegularExpression . class ) ;
1619
1618
1620
- private final Set < Class <?>> types = Set . of ( Pattern . class , BsonRegularExpression . class );
1619
+ static boolean skipConversion ( @ Nullable Object value ) {
1621
1620
1622
- boolean isConversionCandidate (@ Nullable Object value ) {
1623
1621
if (value == null ) {
1624
1622
return false ;
1625
1623
}
1626
1624
1627
- return ! types .contains (value .getClass ());
1625
+ return types .contains (value .getClass ());
1628
1626
}
1629
1627
}
1630
1628
}
0 commit comments