T
- the document typepublic interface CollectibleCodec<T> extends Codec<T>
Modifier and Type | Method and Description |
---|---|
boolean |
documentHasId(T document)
Returns true if the given document has an _id.
|
T |
generateIdIfAbsentFromDocument(T document)
Generates a value for the _id field on the given document, if the document does not have one.
|
BsonValue |
getDocumentId(T document)
Gets the _id of the given document if it contains one, otherwise throws
IllegalArgumentException . |
encode, getEncoderClass
T generateIdIfAbsentFromDocument(T document)
document
- the document for which to generate a value for the _id.boolean documentHasId(T document)
document
- the document in which to look for an _idBsonValue getDocumentId(T document)
IllegalArgumentException
. To avoid the latter case,
call documentHasId
first to check.document
- the document from which to get the _idIllegalStateException
- if the document does not contain an _id