use of org.bson.codecs.Encoder in project morphia by mongodb.
the class IndexHelper method toBsonDocument.
@SuppressWarnings("unchecked")
private BsonDocument toBsonDocument(final String key, final Object value) {
BsonDocumentWriter writer = new BsonDocumentWriter(new BsonDocument());
writer.writeStartDocument();
writer.writeName(key);
((Encoder) database.getCodecRegistry().get(value.getClass())).encode(writer, value, ENCODER_CONTEXT);
writer.writeEndDocument();
return writer.getDocument();
}
Aggregations