Package org.bson.codecs
Class UuidCodec
java.lang.Object
org.bson.codecs.UuidCodec
- Direct Known Subclasses:
OverridableUuidRepresentationUuidCodec
Encodes and decodes
UUID
objects.- Since:
- 3.0
-
Constructor Summary
ConstructorDescriptionThe constructor for UUIDCodec, default is JAVA_LEGACYUuidCodec
(UuidRepresentation uuidRepresentation) The default UUIDRepresentation is JAVA_LEGACY to be compatible with existing documents -
Method Summary
Modifier and TypeMethodDescriptiondecode
(BsonReader reader, DecoderContext decoderContext) Decodes a BSON value from the given reader into an instance of the type parameterT
.void
encode
(BsonWriter writer, UUID value, EncoderContext encoderContext) Encode an instance of the type parameterT
into a BSON value.Returns the Class instance that this encodes.TheUuidRepresentation
with which this instance is configuredtoString()
-
Constructor Details
-
UuidCodec
The default UUIDRepresentation is JAVA_LEGACY to be compatible with existing documents- Parameters:
uuidRepresentation
- the representation of UUID- See Also:
-
UuidCodec
public UuidCodec()The constructor for UUIDCodec, default is JAVA_LEGACY
-
-
Method Details
-
getUuidRepresentation
TheUuidRepresentation
with which this instance is configured- Returns:
- the uuid representation
- Since:
- 3.12
-
encode
Description copied from interface:Encoder
Encode an instance of the type parameterT
into a BSON value. -
decode
Description copied from interface:Decoder
Decodes a BSON value from the given reader into an instance of the type parameterT
. -
getEncoderClass
Description copied from interface:Encoder
Returns the Class instance that this encodes. This is necessary because Java does not reify generic types.- Specified by:
getEncoderClass
in interfaceEncoder<UUID>
- Returns:
- the Class instance that this encodes.
-
toString
-