Package org.bson.codecs
Class MapCodec
- All Implemented Interfaces:
Codec<Map<String,,Object>> Decoder<Map<String,,Object>> Encoder<Map<String,,Object>> OverridableUuidRepresentationCodec<Map<String,,Object>> Parameterizable
public class MapCodec
extends AbstractMapCodec<Object>
implements OverridableUuidRepresentationCodec<Map<String,Object>>, Parameterizable
A Codec for Map instances.
- Since:
- 3.5
-
Constructor Summary
ConstructorsConstructorDescriptionMapCodec()Construct a new instance with a defaultCodecRegistryMapCodec(CodecRegistry registry) Construct a new instance with the given registryMapCodec(CodecRegistry registry, BsonTypeClassMap bsonTypeClassMap) Construct a new instance with the given registry and BSON type class map.MapCodec(CodecRegistry registry, BsonTypeClassMap bsonTypeClassMap, Transformer valueTransformer) Construct a new instance with the given registry and BSON type class map. -
Method Summary
Modifier and TypeMethodDescriptionCodec<?>parameterize(CodecRegistry codecRegistry, List<Type> types) Recursively parameterize the codec with the given registry and generic type arguments.withUuidRepresentation(UuidRepresentation uuidRepresentation) Implementations must return a new instance with theUuidRepresentationoverridden with the given value.Methods inherited from class org.bson.codecs.AbstractMapCodec
decode, encode, getEncoderClass
-
Constructor Details
-
MapCodec
public MapCodec()Construct a new instance with a defaultCodecRegistry -
MapCodec
Construct a new instance with the given registry- Parameters:
registry- the registry
-
MapCodec
Construct a new instance with the given registry and BSON type class map.- Parameters:
registry- the registrybsonTypeClassMap- the BSON type class map
-
MapCodec
public MapCodec(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 map
-
-
Method Details
-
withUuidRepresentation
Description copied from interface:OverridableUuidRepresentationCodecImplementations must return a new instance with theUuidRepresentationoverridden with the given value.- Specified by:
withUuidRepresentationin interfaceOverridableUuidRepresentationCodec<Map<String,Object>> - Parameters:
uuidRepresentation- the UuidRepresentation- Returns:
- a new instance equivalent to this but with the given UuidRepresentation
-
parameterize
Description copied from interface:ParameterizableRecursively parameterize the codec with the given registry and generic type arguments.- Specified by:
parameterizein interfaceParameterizable- Parameters:
codecRegistry- the code registry to use to resolve codecs for the generic type argumentstypes- the types that are parameterizing the containing type.- Returns:
- the Codec parameterized with the given types
-