Browse Source
When the type does not match we simply use the unconverted value. This happens when comparing properties to regexes. Applying the conversion to the String value of the regex doesn't makes sense since we are not dealing with complete values. Users may still provide converters taking Objects and mangle Regex patterns as they desire. Also fixed the null handling of PropertyValueConverters. Removed a few superfluous `@Nullable` annotations where they became obvious Closes #4346issue/4346-property-value-convert-cce
5 changed files with 145 additions and 37 deletions
@ -0,0 +1,44 @@
@@ -0,0 +1,44 @@
|
||||
/* |
||||
* Copyright 2022-2025 the original author or authors. |
||||
* |
||||
* Licensed under the Apache License, Version 2.0 (the "License"); |
||||
* you may not use this file except in compliance with the License. |
||||
* You may obtain a copy of the License at |
||||
* |
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
package org.springframework.data.mongodb.core.convert; |
||||
|
||||
import org.jspecify.annotations.Nullable; |
||||
|
||||
/** |
||||
* @author Jens Schauder |
||||
*/ |
||||
class NullReplacingValueConverter implements MongoValueConverter<String, String> { |
||||
|
||||
@Override |
||||
public @Nullable String read(String value, MongoConversionContext context) { |
||||
return value; |
||||
} |
||||
|
||||
@Override |
||||
public @Nullable String readNull(MongoConversionContext context) { |
||||
return "R"; |
||||
} |
||||
|
||||
@Override |
||||
public @Nullable String write(String value, MongoConversionContext context) { |
||||
return value; |
||||
} |
||||
|
||||
@Override |
||||
public @Nullable String writeNull(MongoConversionContext context) { |
||||
return "W"; |
||||
} |
||||
} |
||||
Loading…
Reference in new issue