Class ParameterBindingDocumentCodec
java.lang.Object
org.springframework.data.mongodb.util.json.ParameterBindingDocumentCodec
- All Implemented Interfaces:
Codec<Document>, CollectibleCodec<Document>, Decoder<Document>, Encoder<Document>
@NullUnmarked
public class ParameterBindingDocumentCodec
extends Object
implements CollectibleCodec<Document>
A
Modified version of MongoDB Inc. DocumentCodec licensed under the Apache License, Version 2.0.
Codec implementation that allows binding parameters to placeholders or SpEL expressions when decoding a
JSON String. Modified version of MongoDB Inc. DocumentCodec licensed under the Apache License, Version 2.0.
- Since:
- 2.2
- Author:
- Jeff Yemin, Ross Lawley, Ralph Schaer, Christoph Strobl, Rocco Lagrotteria
-
Constructor Summary
ConstructorsConstructorDescriptionConstruct a new instance with a defaultCodecRegistry.ParameterBindingDocumentCodec(CodecRegistry registry) Construct a new instance with the given registry.ParameterBindingDocumentCodec(CodecRegistry registry, BsonTypeClassMap bsonTypeClassMap) Construct a new instance with the given registry and BSON type class map.ParameterBindingDocumentCodec(CodecRegistry registry, BsonTypeClassMap bsonTypeClassMap, Transformer valueTransformer) Construct a new instance with the given registry and BSON type class map. -
Method Summary
Modifier and TypeMethodDescriptioncaptureExpressionDependencies(@Nullable String json, ValueProvider valueProvider, ValueExpressionParser expressionParser) DetermineExpressionDependenciesfrom Expressions that are nested in thejsoncontent.decode(@Nullable String json, ParameterBindingContext bindingContext) decode(BsonReader reader, DecoderContext decoderContext) booleandocumentHasId(Document document) voidencode(BsonWriter writer, Document document, EncoderContext encoderContext) generateIdIfAbsentFromDocument(Document document) getDocumentId(Document document)
-
Constructor Details
-
ParameterBindingDocumentCodec
public ParameterBindingDocumentCodec()Construct a new instance with a defaultCodecRegistry. -
ParameterBindingDocumentCodec
Construct a new instance with the given registry.- Parameters:
registry- the registry
-
ParameterBindingDocumentCodec
Construct a new instance with the given registry and BSON type class map.- Parameters:
registry- the registrybsonTypeClassMap- the BSON type class map
-
ParameterBindingDocumentCodec
public ParameterBindingDocumentCodec(CodecRegistry registry, BsonTypeClassMap bsonTypeClassMap, Transformer valueTransformer) Construct a new instance with the given registry and BSON type class map. The transformer is applied as a last step when decoding values, which allows users of this codec to control the decoding process. For example, a user of this class could substitute a value decoded as a Document with an instance of a special purpose class (e.g., one representing a DBRef in MongoDB).- Parameters:
registry- the registrybsonTypeClassMap- the BSON type class mapvalueTransformer- the value transformer to use as a final step when decoding the value of any field in the document
-
-
Method Details
-
documentHasId
- Specified by:
documentHasIdin interfaceCollectibleCodec<Document>
-
getDocumentId
- Specified by:
getDocumentIdin interfaceCollectibleCodec<Document>
-
generateIdIfAbsentFromDocument
- Specified by:
generateIdIfAbsentFromDocumentin interfaceCollectibleCodec<Document>
-
encode
-
decode
-
decode
-
captureExpressionDependencies
public ExpressionDependencies captureExpressionDependencies(@Nullable String json, ValueProvider valueProvider, ValueExpressionParser expressionParser) DetermineExpressionDependenciesfrom Expressions that are nested in thejsoncontent. ReturnsOptional.empty()ifjsonis empty or of it does not contain any SpEL expressions.- Parameters:
json-expressionParser-- Returns:
- merged
ExpressionDependenciesobject if expressions were found, otherwiseExpressionDependencies.none(). - Since:
- 3.1
-
decode
-
getEncoderClass
- Specified by:
getEncoderClassin interfaceEncoder<Document>
-