diff --git a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/util/json/DateTimeFormatter.java b/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/util/json/DateTimeFormatter.java
index d9c16c1c1..ff1cbd6db 100644
--- a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/util/json/DateTimeFormatter.java
+++ b/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/util/json/DateTimeFormatter.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2019 the original author or authors.
+ * Copyright 2008-2019 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.
@@ -34,9 +34,9 @@ import java.util.TimeZone;
* Inc. licensed under the Apache License, Version 2.0.
* Formatted and modified.
*
- * @since 2.2
* @author Jeff Yemin
* @author Ross Lawley
+ * @since 2.2
*/
class DateTimeFormatter {
diff --git a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/util/json/JsonBuffer.java b/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/util/json/JsonBuffer.java
index 185a90d4c..de7eef287 100644
--- a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/util/json/JsonBuffer.java
+++ b/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/util/json/JsonBuffer.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2019 the original author or authors.
+ * Copyright 2008-2019 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.
@@ -22,10 +22,10 @@ import org.bson.json.JsonParseException;
* "https://github.com/mongodb/mongo-java-driver/blob/master/bson/src/main/org/bson/json/JsonBuffer.java">MongoDB
* Inc. licensed under the Apache License, Version 2.0.
* Formatted and modified.
- *
- * @since 2.2
+ *
* @author Jeff Yemin
* @author Ross Lawley
+ * @since 2.2
*/
class JsonBuffer {
diff --git a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/util/json/JsonScanner.java b/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/util/json/JsonScanner.java
index f38a2a8ca..6534f4a10 100644
--- a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/util/json/JsonScanner.java
+++ b/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/util/json/JsonScanner.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2019 the original author or authors.
+ * Copyright 2008-2019 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.
@@ -24,13 +24,13 @@ import org.bson.json.JsonParseException;
* "https://github.com/mongodb/mongo-java-driver/blob/master/bson/src/main/org/bson/json/JsonScanner.java">MongoDB
* Inc. licensed under the Apache License, Version 2.0.
* Formatted and modified to allow reading Spring Data specific placeholder values.
- *
- * @since 2.2
+ *
* @author Jeff Yemin
* @author Trisha Gee
* @author Robert Guo
* @author Ross Lawley
* @author Christoph Strobl
+ * @since 2.2
*/
class JsonScanner {
@@ -122,13 +122,13 @@ class JsonScanner {
/**
* Reads {@code RegularExpressionToken} from source. The following variants of lexemes are possible:
- *
+ *
*
* /pattern/ * /\(pattern\)/ * /pattern/ims *- * + * * Options can include 'i','m','x','s' * * @return The regular expression token. @@ -295,7 +295,7 @@ class JsonScanner { /** * Reads number token from source. The following variants of lexemes are possible: - * + * *
* 12 * 123 diff --git a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/util/json/JsonToken.java b/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/util/json/JsonToken.java index 2b13ebde4..8f3195151 100644 --- a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/util/json/JsonToken.java +++ b/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/util/json/JsonToken.java @@ -1,5 +1,5 @@ /* - * Copyright 2019 the original author or authors. + * Copyright 2008-2019 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. @@ -26,9 +26,9 @@ import org.bson.types.Decimal128; * "https://github.com/mongodb/mongo-java-driver/blob/master/bson/src/main/org/bson/json/JsonToken.java">MongoDB * Inc. licensed under the Apache License, Version 2.0.
* - * @since 2.2 * @author Jeff Yemin * @author Ross Lawley + * @since 2.2 */ class JsonToken { diff --git a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/util/json/JsonTokenType.java b/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/util/json/JsonTokenType.java index bda090c92..0bc2a9891 100644 --- a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/util/json/JsonTokenType.java +++ b/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/util/json/JsonTokenType.java @@ -1,5 +1,5 @@ /* - * Copyright 2019 the original author or authors. + * Copyright 2008-2019 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. @@ -20,9 +20,9 @@ package org.springframework.data.mongodb.util.json; * "https://github.com/mongodb/mongo-java-driver/blob/master/bson/src/main/org/bson/json/JsonTokenType.java">MongoDB * Inc. licensed under the Apache License, Version 2.0.
* - * @since 2.2 * @author Jeff Yemin * @author Ross Lawley + * @since 2.2 */ enum JsonTokenType { /** diff --git a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/util/json/ParameterBindingDocumentCodec.java b/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/util/json/ParameterBindingDocumentCodec.java index 740cd6add..f0d7d311a 100644 --- a/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/util/json/ParameterBindingDocumentCodec.java +++ b/spring-data-mongodb/src/main/java/org/springframework/data/mongodb/util/json/ParameterBindingDocumentCodec.java @@ -1,5 +1,5 @@ /* - * Copyright 2019 the original author or authors. + * Copyright 2008-2019 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. @@ -35,8 +35,19 @@ import org.bson.BsonValue; import org.bson.BsonWriter; import org.bson.Document; import org.bson.Transformer; -import org.bson.codecs.*; +import org.bson.codecs.BsonTypeClassMap; +import org.bson.codecs.BsonTypeCodecMap; +import org.bson.codecs.BsonValueCodecProvider; +import org.bson.codecs.Codec; +import org.bson.codecs.CollectibleCodec; +import org.bson.codecs.DecoderContext; +import org.bson.codecs.DocumentCodecProvider; +import org.bson.codecs.EncoderContext; +import org.bson.codecs.IdGenerator; +import org.bson.codecs.ObjectIdGenerator; +import org.bson.codecs.ValueCodecProvider; import org.bson.codecs.configuration.CodecRegistry; + import org.springframework.data.spel.EvaluationContextProvider; import org.springframework.expression.spel.standard.SpelExpressionParser; import org.springframework.lang.Nullable; @@ -49,11 +60,11 @@ import org.springframework.util.StringUtils; * "https://github.com/mongodb/mongo-java-driver/blob/master/bson/src/main/org/bson/codecs/DocumentCodec.java">MongoDB * Inc. DocumentCodec licensed under the Apache License, Version 2.0.
* - * @since 2.2 * @author Jeff Yemin * @author Ross Lawley * @author Ralph Schaer * @author Christoph Strobl + * @since 2.2 */ public class ParameterBindingDocumentCodec implements CollectibleCodec{ @@ -78,7 +89,6 @@ public class ParameterBindingDocumentCodec implements CollectibleCodec * Construct a new instance with the given registry. * * @param registry the registry - * @since 3.5 */ public ParameterBindingDocumentCodec(final CodecRegistry registry) { this(registry, DEFAULT_BSON_TYPE_CLASS_MAP); @@ -156,6 +166,7 @@ public class ParameterBindingDocumentCodec implements CollectibleCodec writeMap(writer, document, encoderContext); } + // Spring Data Customization START public Document decode(@Nullable String json, Object[] values) { return decode(json, new ParameterBindingContext((index) -> values[index], new SpelExpressionParser(), @@ -197,6 +208,8 @@ public class ParameterBindingDocumentCodec implements CollectibleCodec return document; } + // Spring Data Customization END + @Override public Class getEncoderClass() { return Document.class; @@ -254,11 +267,12 @@ public class ParameterBindingDocumentCodec implements CollectibleCodec private Object readValue(final BsonReader reader, final DecoderContext decoderContext) { + // Spring Data Customization START if (reader instanceof ParameterBindingJsonReader) { ParameterBindingJsonReader bindingReader = (ParameterBindingJsonReader) reader; - // check if the reader has actually found something to replaceand did so. + // check if the reader has actually found something to replace and did so. // resets the reader state to move on after the actual value // returns the replacement value if (bindingReader.currentValue != null) { @@ -270,6 +284,8 @@ public class ParameterBindingDocumentCodec implements CollectibleCodec } } + // Spring Data Customization END + BsonType bsonType = reader.getCurrentBsonType(); if (bsonType == BsonType.NULL) { reader.readNull(); @@ -281,6 +297,7 @@ public class ParameterBindingDocumentCodec implements CollectibleCodec return registry.get(UUID.class).decode(reader, decoderContext); } + // Spring Data Customization START // By default the registry uses DocumentCodec for parsing. // We need to reroute that to our very own implementation or we'll end up only mapping half the placeholders. Codec> codecToUse = bsonTypeCodecMap.get(bsonType); @@ -289,6 +306,7 @@ public class ParameterBindingDocumentCodec implements CollectibleCodec } return valueTransformer.transform(codecToUse.decode(reader, decoderContext)); + // Spring Data Customization END } private List