Java Code Examples for org.bson.conversions.Bson#toBsonDocument()
The following examples show how to use
org.bson.conversions.Bson#toBsonDocument() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Operations.java From stitch-android-sdk with Apache License 2.0 | 8 votes |
<ResultT> FindOneOperation<ResultT> findOne( final Bson filter, final RemoteFindOptions options, final Class<ResultT> resultClass ) { BsonDocument projection = null; BsonDocument sort = null; if (options != null) { projection = BsonUtils.toBsonDocumentOrNull( options.getProjection(), documentClass, codecRegistry); sort = BsonUtils.toBsonDocumentOrNull(options.getSort(), documentClass, codecRegistry); } return new FindOneOperation<>( namespace, filter.toBsonDocument(documentClass, codecRegistry), projection, sort, codecRegistry.get(resultClass)); }
Example 2
Source File: SyncOperations.java From stitch-android-sdk with Apache License 2.0 | 8 votes |
<ResultT> FindOneOperation<ResultT> findOne( final Bson filter, final RemoteFindOptions options, final Class<ResultT> resultClass ) { BsonDocument projection = null; BsonDocument sort = null; if (options != null) { projection = BsonUtils.toBsonDocumentOrNull( options.getProjection(), documentClass, codecRegistry); sort = BsonUtils.toBsonDocumentOrNull(options.getSort(), documentClass, codecRegistry); } return new FindOneOperation<>( namespace, resultClass, filter.toBsonDocument(documentClass, codecRegistry), projection, sort, dataSynchronizer); }
Example 3
Source File: SyncOperations.java From stitch-android-sdk with Apache License 2.0 | 6 votes |
private <ResultT> SyncFindOperation<ResultT> createSyncFindOperation( final MongoNamespace findNamespace, final Bson filter, final Class<ResultT> resultClass, final RemoteFindOptions options ) { final BsonDocument filterDoc = filter.toBsonDocument(documentClass, codecRegistry); final BsonDocument projDoc = BsonUtils.toBsonDocumentOrNull( options.getProjection(), documentClass, codecRegistry); final BsonDocument sortDoc = BsonUtils.toBsonDocumentOrNull( options.getSort(), documentClass, codecRegistry); return new SyncFindOperation<>( findNamespace, resultClass, dataSynchronizer) .filter(filterDoc) .limit(options.getLimit()) .projection(projDoc) .sort(sortDoc); }
Example 4
Source File: BsonUtils.java From stitch-android-sdk with Apache License 2.0 | 5 votes |
public static <T> BsonDocument toBsonDocument( final Bson bson, final Class<T> documentClass, final CodecRegistry codecRegistry ) { return bson == null ? null : bson.toBsonDocument(documentClass, codecRegistry); }
Example 5
Source File: BsonUtils.java From stitch-android-sdk with Apache License 2.0 | 5 votes |
public static <T> BsonDocument toBsonDocumentOrNull( final Bson document, final Class<T> documentClass, final CodecRegistry codecRegistry ) { return document == null ? null : document.toBsonDocument(documentClass, codecRegistry); }
Example 6
Source File: FindQuery.java From beam with Apache License 2.0 | 4 votes |
/** Convert the Bson filters into a BsonDocument via default encoding. */ static BsonDocument bson2BsonDocument(Bson filters) { return filters.toBsonDocument(BasicDBObject.class, MongoClient.getDefaultCodecRegistry()); }
Example 7
Source File: BsonUtil.java From ditto with Eclipse Public License 2.0 | 2 votes |
/** * Converts the given {@link Bson} object to a {@link BsonDocument}. * * @param bsonObj the Bson object. * @return the Bson document. * @throws NullPointerException if {@code bsonObj} is {@code null}. */ public static BsonDocument toBsonDocument(final Bson bsonObj) { checkNotNull(bsonObj, "BSON object to be converted"); return bsonObj.toBsonDocument(BsonDocument.class, CODEC_REGISTRY); }