public class DBObjectCodec extends java.lang.Object implements CollectibleCodec<DBObject>, OverridableUuidRepresentationCodec<DBObject>
| Constructor and Description |
|---|
DBObjectCodec()
Construct an instance with the default codec registry
|
DBObjectCodec(CodecRegistry codecRegistry)
Construct an instance with the given codec registry.
|
DBObjectCodec(CodecRegistry codecRegistry,
BsonTypeClassMap bsonTypeClassMap)
Construct an instance.
|
DBObjectCodec(CodecRegistry codecRegistry,
BsonTypeClassMap bsonTypeClassMap,
com.mongodb.DBObjectFactory objectFactory)
Construct an instance.
|
| Modifier and Type | Method and Description |
|---|---|
DBObject |
decode(BsonReader reader,
DecoderContext decoderContext)
Decodes a BSON value from the given reader into an instance of the type parameter
T. |
boolean |
documentHasId(DBObject document)
Returns true if the given document has an _id.
|
void |
encode(BsonWriter writer,
DBObject document,
EncoderContext encoderContext)
Encode an instance of the type parameter
T into a BSON value. |
DBObject |
generateIdIfAbsentFromDocument(DBObject document)
Generates a value for the _id field on the given document, if the document does not have one.
|
BsonValue |
getDocumentId(DBObject document)
Gets the _id of the given document if it contains one, otherwise throws
IllegalArgumentException. |
java.lang.Class<DBObject> |
getEncoderClass()
Returns the Class instance that this encodes.
|
Codec<DBObject> |
withUuidRepresentation(UuidRepresentation uuidRepresentation)
Implementations must return a new instance with the
UuidRepresentation overridden with the given value. |
public DBObjectCodec()
public DBObjectCodec(CodecRegistry codecRegistry)
codecRegistry - the non-null codec registrypublic DBObjectCodec(CodecRegistry codecRegistry, BsonTypeClassMap bsonTypeClassMap)
codecRegistry - the codec registrybsonTypeClassMap - the non-null BsonTypeClassMappublic DBObjectCodec(CodecRegistry codecRegistry, BsonTypeClassMap bsonTypeClassMap, com.mongodb.DBObjectFactory objectFactory)
codecRegistry - the non-null codec registrybsonTypeClassMap - the non-null BsonTypeClassMapobjectFactory - the non-null object factory used to create empty DBObject instances when decodingpublic void encode(BsonWriter writer, DBObject document, EncoderContext encoderContext)
EncoderT into a BSON value.public DBObject decode(BsonReader reader, DecoderContext decoderContext)
DecoderT.public java.lang.Class<DBObject> getEncoderClass()
EncodergetEncoderClass in interface Encoder<DBObject>public boolean documentHasId(DBObject document)
CollectibleCodecdocumentHasId in interface CollectibleCodec<DBObject>document - the document in which to look for an _idpublic BsonValue getDocumentId(DBObject document)
CollectibleCodecIllegalArgumentException. To avoid the latter case,
call documentHasId first to check.getDocumentId in interface CollectibleCodec<DBObject>document - the document from which to get the _idpublic DBObject generateIdIfAbsentFromDocument(DBObject document)
CollectibleCodecgenerateIdIfAbsentFromDocument in interface CollectibleCodec<DBObject>document - the document for which to generate a value for the _id.public Codec<DBObject> withUuidRepresentation(UuidRepresentation uuidRepresentation)
OverridableUuidRepresentationCodecUuidRepresentation overridden with the given value.withUuidRepresentation in interface OverridableUuidRepresentationCodec<DBObject>uuidRepresentation - the UuidRepresentationCopyright © 2010 - 2023 Adobe. All Rights Reserved