Polishing.
Refine default conversions creation. See #4014 Original pull request: #4015.
This commit is contained in:
@@ -156,8 +156,8 @@ public class MongoCustomConversions extends org.springframework.data.convert.Cus
|
||||
private boolean useNativeDriverJavaTimeCodecs = false;
|
||||
private final List<Object> customConverters = new ArrayList<>();
|
||||
|
||||
private PropertyValueConversions propertyValueConversions = PropertyValueConversions.simple(it -> {});
|
||||
private PropertyValueConversions internallyCreatedValueConversion = propertyValueConversions;
|
||||
private final PropertyValueConversions internalValueConversion = PropertyValueConversions.simple(it -> {});
|
||||
private PropertyValueConversions propertyValueConversions = internalValueConversion;
|
||||
|
||||
/**
|
||||
* Create a {@link MongoConverterConfigurationAdapter} using the provided {@code converters} and our own codecs for
|
||||
@@ -178,7 +178,7 @@ public class MongoCustomConversions extends org.springframework.data.convert.Cus
|
||||
}
|
||||
|
||||
/**
|
||||
* Set whether or not to use the native MongoDB Java Driver {@link org.bson.codecs.Codec codes} for
|
||||
* Set whether to or not to use the native MongoDB Java Driver {@link org.bson.codecs.Codec codes} for
|
||||
* {@link org.bson.codecs.jsr310.LocalDateCodec LocalDate}, {@link org.bson.codecs.jsr310.LocalTimeCodec LocalTime}
|
||||
* and {@link org.bson.codecs.jsr310.LocalDateTimeCodec LocalDateTime} using a {@link ZoneOffset#UTC}.
|
||||
*
|
||||
@@ -318,7 +318,7 @@ public class MongoCustomConversions extends org.springframework.data.convert.Cus
|
||||
PropertyValueConversions valueConversions() {
|
||||
|
||||
if (this.propertyValueConversions == null) {
|
||||
this.propertyValueConversions = PropertyValueConversions.simple(it -> {});
|
||||
this.propertyValueConversions = internalValueConversion;
|
||||
}
|
||||
|
||||
return this.propertyValueConversions;
|
||||
@@ -326,7 +326,8 @@ public class MongoCustomConversions extends org.springframework.data.convert.Cus
|
||||
|
||||
ConverterConfiguration createConverterConfiguration() {
|
||||
|
||||
if(isLocallyCreatedPropertyValueConversion() && propertyValueConversions instanceof SimplePropertyValueConversions svc) {
|
||||
if (hasDefaultPropertyValueConversions()
|
||||
&& propertyValueConversions instanceof SimplePropertyValueConversions svc) {
|
||||
svc.init();
|
||||
}
|
||||
|
||||
@@ -387,8 +388,8 @@ public class MongoCustomConversions extends org.springframework.data.convert.Cus
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isLocallyCreatedPropertyValueConversion() {
|
||||
return propertyValueConversions == internallyCreatedValueConversion;
|
||||
private boolean hasDefaultPropertyValueConversions() {
|
||||
return propertyValueConversions == internalValueConversion;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user