org.bson.codecs.CollectibleCodec Java Examples
The following examples show how to use
org.bson.codecs.CollectibleCodec.
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 | 6 votes |
InsertManyOperation insertMany( final List<? extends DocumentT> documents ) { notNull("documents", documents); final List<BsonDocument> docs = new ArrayList<>(documents.size()); for (final DocumentT document : documents) { if (document == null) { throw new IllegalArgumentException("documents can not contain a null value"); } final DocumentT docToAdd; if (getCodec(codecRegistry, documentClass) instanceof CollectibleCodec) { docToAdd = ((CollectibleCodec<DocumentT>) getCodec(codecRegistry, documentClass)) .generateIdIfAbsentFromDocument(document); } else { docToAdd = document; } docs.add(documentToBsonDocument(docToAdd, codecRegistry)); } return new InsertManyOperation(namespace, docs); }
Example #2
Source File: SyncOperations.java From stitch-android-sdk with Apache License 2.0 | 6 votes |
public InsertOneOperation insertOne(final DocumentT document) { notNull("document", document); final DocumentT docToInsert; if (getCodec(codecRegistry, documentClass) instanceof CollectibleCodec) { docToInsert = ((CollectibleCodec<DocumentT>) getCodec(codecRegistry, documentClass)) .generateIdIfAbsentFromDocument(document); } else { docToInsert = document; } return new InsertOneOperation( namespace, documentToBsonDocument(docToInsert, codecRegistry), dataSynchronizer); }
Example #3
Source File: SyncOperations.java From stitch-android-sdk with Apache License 2.0 | 6 votes |
InsertManyOperation insertMany(final List<DocumentT> documents) { final List<BsonDocument> bsonDocuments = new ArrayList<>(); for (final DocumentT document : documents) { if (getCodec(codecRegistry, documentClass) instanceof CollectibleCodec) { bsonDocuments.add( documentToBsonDocument( ((CollectibleCodec<DocumentT>) getCodec(codecRegistry, documentClass)) .generateIdIfAbsentFromDocument(document), codecRegistry ) ); } else { bsonDocuments.add(documentToBsonDocument(document, codecRegistry)); } } return new InsertManyOperation( namespace, bsonDocuments, dataSynchronizer); }
Example #4
Source File: Operations.java From stitch-android-sdk with Apache License 2.0 | 5 votes |
InsertOneOperation insertOne(final DocumentT document) { notNull("document", document); final DocumentT docToInsert; if (getCodec(codecRegistry, documentClass) instanceof CollectibleCodec) { docToInsert = ((CollectibleCodec<DocumentT>) getCodec(codecRegistry, documentClass)) .generateIdIfAbsentFromDocument(document); } else { docToInsert = document; } return new InsertOneOperation(namespace, documentToBsonDocument(docToInsert, codecRegistry)); }