Skip to content

Commit 513e6a0

Browse files
committed
DATAMONGO-2315 - Polishing.
Tweak method name. Javadoc. Original pull request: #772.
1 parent 8ca16e1 commit 513e6a0

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

spring-data-mongodb/src/main/java/org/springframework/data/mongodb/util/json/ParameterBindingJsonReader.java

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -394,7 +394,7 @@ private BindableValue bindableValueFor(JsonToken token) {
394394
matched = true;
395395
String group = matcher.group();
396396
int index = computeParameterIndex(group);
397-
computedValue = computedValue.replace(group, nullSaveToString(getBindableValueForIndex(index)));
397+
computedValue = computedValue.replace(group, nullSafeToString(getBindableValueForIndex(index)));
398398
}
399399

400400
if (!matched) {
@@ -406,7 +406,7 @@ private BindableValue bindableValueFor(JsonToken token) {
406406
String binding = regexMatcher.group();
407407
String expression = binding.substring(3, binding.length() - 1);
408408

409-
computedValue = computedValue.replace(binding, nullSaveToString(evaluateExpression(expression)));
409+
computedValue = computedValue.replace(binding, nullSafeToString(evaluateExpression(expression)));
410410
}
411411
}
412412

@@ -416,7 +416,7 @@ private BindableValue bindableValueFor(JsonToken token) {
416416
return bindableValue;
417417
}
418418

419-
private static String nullSaveToString(Object value) {
419+
private static String nullSafeToString(@Nullable Object value) {
420420

421421
if (value instanceof Date) {
422422
return DateTimeFormatter.format(((Date) value).getTime());
@@ -1256,6 +1256,8 @@ private long visitDateTimeExtendedJson() {
12561256
} else if (valueToken.getType() == JsonTokenType.STRING
12571257
|| valueToken.getType() == JsonTokenType.UNQUOTED_STRING) {
12581258

1259+
// Spring Data Customization START
1260+
12591261
Object dt = bindableValueFor(valueToken).getValue();
12601262
if (dt instanceof Date) {
12611263
value = ((Date) dt).getTime();
@@ -1268,6 +1270,8 @@ private long visitDateTimeExtendedJson() {
12681270
throw new JsonParseException(String.format("Failed to parse string '%s' as a date", dt), e);
12691271
}
12701272
}
1273+
1274+
// Spring Data Customization END
12711275
} else {
12721276
throw new JsonParseException("JSON reader expected an integer or string but found '%s'.",
12731277
valueToken.getValue());

spring-data-mongodb/src/test/java/org/springframework/data/mongodb/util/json/ParameterBindingJsonReaderUnitTests.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@
2828
import org.junit.Test;
2929

3030
/**
31+
* Unit tests for {@link ParameterBindingJsonReader}.
32+
*
3133
* @author Christoph Strobl
3234
*/
3335
public class ParameterBindingJsonReaderUnitTests {

0 commit comments

Comments
 (0)