@@ -816,7 +816,7 @@ public Object convertId(@Nullable Object id) {
816816 @ Nullable
817817 public Object convertId (@ Nullable Object id , Class <?> targetType ) {
818818
819- if (! SpecialTypeTreatment . INSTANCE . isConversionCandidate (id )) {
819+ if (Quirks . skipConversion (id )) {
820820 return id ;
821821 }
822822
@@ -881,8 +881,7 @@ protected boolean isKeyword(String candidate) {
881881 private Object applyFieldTargetTypeHintToValue (Field documentField , @ Nullable Object value ) {
882882
883883 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 )) {
886885 return value ;
887886 }
888887
@@ -1611,20 +1610,19 @@ public <T> T getPropertyValue(MongoPersistentProperty property) {
16111610 }
16121611
16131612 /*
1614- * Types that must not be converted
1613+ * Types that must not be converted.
16151614 */
1616- enum SpecialTypeTreatment {
1615+ static class Quirks {
16171616
1618- INSTANCE ;
1617+ private static final Set < Class <?>> types = Set . of ( Pattern . class , BsonRegularExpression . class ) ;
16191618
1620- private final Set < Class <?>> types = Set . of ( Pattern . class , BsonRegularExpression . class );
1619+ static boolean skipConversion ( @ Nullable Object value ) {
16211620
1622- boolean isConversionCandidate (@ Nullable Object value ) {
16231621 if (value == null ) {
16241622 return false ;
16251623 }
16261624
1627- return ! types .contains (value .getClass ());
1625+ return types .contains (value .getClass ());
16281626 }
16291627 }
16301628}
0 commit comments