Constructor | 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 | 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 . |
Class<DBObject> |
getEncoderClass() |
Returns the Class instance that this encodes.
|
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)
Encoder
T
into a BSON value.public DBObject decode(BsonReader reader, DecoderContext decoderContext)
Decoder
T
.public Class<DBObject> getEncoderClass()
Encoder
getEncoderClass
in interface Encoder<DBObject>
public boolean documentHasId(DBObject document)
CollectibleCodec
documentHasId
in interface CollectibleCodec<DBObject>
document
- the document in which to look for an _idpublic BsonValue getDocumentId(DBObject document)
CollectibleCodec
IllegalArgumentException
. 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)
CollectibleCodec
generateIdIfAbsentFromDocument
in interface CollectibleCodec<DBObject>
document
- the document for which to generate a value for the _id.