Class CoreSyncImpl<DocumentT>

  • All Implemented Interfaces:
    CoreSync<DocumentT>

    public class CoreSyncImpl<DocumentT>
    extends Object
    implements CoreSync<DocumentT>
    • Method Detail

      • configure

        public void configure​(@Nonnull
                              SyncConfiguration syncConfig)
        Description copied from interface: CoreSync
        Set the conflict resolver and and change event listener on this collection.
        Specified by:
        configure in interface CoreSync<DocumentT>
        Parameters:
        syncConfig - the SyncConfiguration that contains relevant options
      • updateSyncFrequency

        public void updateSyncFrequency​(@Nonnull
                                        SyncFrequency syncFrequency)
        Set the SyncFrequency on this collection.
        Specified by:
        updateSyncFrequency in interface CoreSync<DocumentT>
        Parameters:
        syncFrequency - the SyncFrequency that contains relevant options
      • syncOne

        public void syncOne​(BsonValue id)
        Description copied from interface: CoreSync
        Requests that the given document _id be synchronized.
        Specified by:
        syncOne in interface CoreSync<DocumentT>
        Parameters:
        id - the document _id to synchronize.
      • syncMany

        public void syncMany​(BsonValue... ids)
        Description copied from interface: CoreSync
        Requests that the given document _ids be synchronized.
        Specified by:
        syncMany in interface CoreSync<DocumentT>
        Parameters:
        ids - the document _ids to synchronize.
      • desyncOne

        public void desyncOne​(BsonValue id)
        Description copied from interface: CoreSync
        Stops synchronizing the given document _id. Any uncommitted writes will be lost.
        Specified by:
        desyncOne in interface CoreSync<DocumentT>
        Parameters:
        id - the _id of the document to desynchronize.
      • desyncMany

        public void desyncMany​(BsonValue... ids)
        Description copied from interface: CoreSync
        Stops synchronizing the given document _ids. Any uncommitted writes will be lost.
        Specified by:
        desyncMany in interface CoreSync<DocumentT>
        Parameters:
        ids - the _ids of the documents to desynchronize.
      • getSyncedIds

        public Set<BsonValue> getSyncedIds()
        Description copied from interface: CoreSync
        Returns the set of synchronized document ids in a namespace.
        Specified by:
        getSyncedIds in interface CoreSync<DocumentT>
        Returns:
        the set of synchronized document ids in a namespace.
      • getPausedDocumentIds

        public Set<BsonValue> getPausedDocumentIds()
        Description copied from interface: CoreSync
        Return the set of synchronized document _ids in a namespace that have been paused due to an irrecoverable error.
        Specified by:
        getPausedDocumentIds in interface CoreSync<DocumentT>
        Returns:
        the set of paused document _ids in a namespace
      • resumeSyncForDocument

        public boolean resumeSyncForDocument​(BsonValue documentId)
        Description copied from interface: CoreSync
        A document that is paused no longer has remote updates applied to it. Any local updates to this document cause it to be resumed. An example of pausing a document is when a conflict is being resolved for that document and the handler throws an exception.
        Specified by:
        resumeSyncForDocument in interface CoreSync<DocumentT>
        Parameters:
        documentId - the id of the document to resume syncing
        Returns:
        true if successfully resumed, false if the document could not be found or there was an error resuming
      • count

        public long count()
        Description copied from interface: CoreSync
        Counts the number of documents in the collection that have been synchronized with the remote.
        Specified by:
        count in interface CoreSync<DocumentT>
        Returns:
        the number of documents in the collection
      • count

        public long count​(Bson filter)
        Description copied from interface: CoreSync
        Counts the number of documents in the collection that have been synchronized with the remote according to the given options.
        Specified by:
        count in interface CoreSync<DocumentT>
        Parameters:
        filter - the query filter
        Returns:
        the number of documents in the collection
      • count

        public long count​(Bson filter,
                          SyncCountOptions options)
        Description copied from interface: CoreSync
        Counts the number of documents in the collection that have been synchronized with the remote according to the given options.
        Specified by:
        count in interface CoreSync<DocumentT>
        Parameters:
        filter - the query filter
        options - the options describing the count
        Returns:
        the number of documents in the collection
      • aggregate

        public CoreSyncAggregateIterable<DocumentT> aggregate​(List<? extends Bson> pipeline)
        Description copied from interface: CoreSync
        Aggregates documents that have been synchronized with the remote according to the specified aggregation pipeline.
        Specified by:
        aggregate in interface CoreSync<DocumentT>
        Parameters:
        pipeline - the aggregation pipeline
        Returns:
        an iterable containing the result of the aggregation operation
      • aggregate

        public <ResultT> CoreSyncAggregateIterable<ResultT> aggregate​(List<? extends Bson> pipeline,
                                                                      Class<ResultT> resultClass)
        Description copied from interface: CoreSync
        Aggregates documents that have been synchronized with the remote according to the specified aggregation pipeline.
        Specified by:
        aggregate in interface CoreSync<DocumentT>
        Type Parameters:
        ResultT - the target document type of the iterable.
        Parameters:
        pipeline - the aggregation pipeline
        resultClass - the class to decode each document into
        Returns:
        an iterable containing the result of the aggregation operation
      • updateOne

        public SyncUpdateResult updateOne​(Bson filter,
                                          Bson update)
        Description copied from interface: CoreSync
        Update a single document in the collection that have been synchronized with the remote according to the specified arguments. If the update results in an upsert, the newly upserted document will automatically become synchronized.
        Specified by:
        updateOne in interface CoreSync<DocumentT>
        Parameters:
        filter - a document describing the query filter, which may not be null.
        update - a document describing the update, which may not be null. The update to apply must include only update operators.
        Returns:
        the result of the update one operation
      • updateOne

        public SyncUpdateResult updateOne​(Bson filter,
                                          Bson update,
                                          SyncUpdateOptions updateOptions)
        Description copied from interface: CoreSync
        Update a single document in the collection that has been synchronized with the remote according to the specified arguments. If the update results in an upsert, the newly upserted document will automatically become synchronized.
        Specified by:
        updateOne in interface CoreSync<DocumentT>
        Parameters:
        filter - a document describing the query filter, which may not be null.
        update - a document describing the update, which may not be null. The update to apply must include only update operators.
        updateOptions - the options to apply to the update operation
        Returns:
        the result of the update one operation
      • updateMany

        public SyncUpdateResult updateMany​(Bson filter,
                                           Bson update)
        Description copied from interface: CoreSync
        Update all documents in the collection that have been synchronized with the remote according to the specified arguments. If the update results in an upsert, the newly upserted document will automatically become synchronized.
        Specified by:
        updateMany in interface CoreSync<DocumentT>
        Parameters:
        filter - a document describing the query filter, which may not be null.
        update - a document describing the update, which may not be null. The update to apply must include only update operators.
        Returns:
        the result of the update many operation
      • updateMany

        public SyncUpdateResult updateMany​(Bson filter,
                                           Bson update,
                                           SyncUpdateOptions updateOptions)
        Description copied from interface: CoreSync
        Update all documents in the collection that have been synchronized with the remote according to the specified arguments. If the update results in an upsert, the newly upserted document will automatically become synchronized.
        Specified by:
        updateMany in interface CoreSync<DocumentT>
        Parameters:
        filter - a document describing the query filter, which may not be null.
        update - a document describing the update, which may not be null. The update to apply must include only update operators.
        updateOptions - the options to apply to the update operation
        Returns:
        the result of the update many operation
      • insertOne

        public SyncInsertOneResult insertOne​(DocumentT document)
        Description copied from interface: CoreSync
        Inserts the provided document. If the document is missing an identifier, the client should generate one. Syncs the newly inserted document against the remote.
        Specified by:
        insertOne in interface CoreSync<DocumentT>
        Parameters:
        document - the document to insert
        Returns:
        the result of the insert one operation
      • insertMany

        public SyncInsertManyResult insertMany​(List<DocumentT> documents)
        Description copied from interface: CoreSync
        Inserts one or more documents. Syncs the newly inserted documents against the remote.
        Specified by:
        insertMany in interface CoreSync<DocumentT>
        Parameters:
        documents - the documents to insert
        Returns:
        the result of the insert many operation
      • deleteOne

        public SyncDeleteResult deleteOne​(Bson filter)
        Description copied from interface: CoreSync
        Removes at most one document from the collection that has been synchronized with the remote that matches the given filter. If no documents match, the collection is not modified.
        Specified by:
        deleteOne in interface CoreSync<DocumentT>
        Parameters:
        filter - the query filter to apply the the delete operation
        Returns:
        the result of the remove one operation
      • deleteMany

        public SyncDeleteResult deleteMany​(Bson filter)
        Description copied from interface: CoreSync
        Removes all documents from the collection that have been synchronized with the remote that match the given query filter. If no documents match, the collection is not modified.
        Specified by:
        deleteMany in interface CoreSync<DocumentT>
        Parameters:
        filter - the query filter to apply the the delete operation
        Returns:
        the result of the remove many operation
      • findOne

        public DocumentT findOne()
        Description copied from interface: CoreSync
        Finds a document in the collection.
        Specified by:
        findOne in interface CoreSync<DocumentT>
        Returns:
        the resulting document
      • findOne

        public DocumentT findOne​(Bson filter)
        Description copied from interface: CoreSync
        Finds a document in the collection.
        Specified by:
        findOne in interface CoreSync<DocumentT>
        Parameters:
        filter - the query filter
        Returns:
        the resulting document
      • findOne

        public DocumentT findOne​(Bson filter,
                                 RemoteFindOptions options)
        Description copied from interface: CoreSync
        Finds a document in the collection.
        Specified by:
        findOne in interface CoreSync<DocumentT>
        Parameters:
        filter - the query filter
        options - A RemoteFindOptions struct
        Returns:
        the resulting document
      • findOne

        public <ResultT> ResultT findOne​(Class<ResultT> resultClass)
        Description copied from interface: CoreSync
        Finds a document in the collection.
        Specified by:
        findOne in interface CoreSync<DocumentT>
        Type Parameters:
        ResultT - the target document type
        Parameters:
        resultClass - the class to decode each document into
        Returns:
        the resulting document
      • findOne

        public <ResultT> ResultT findOne​(Bson filter,
                                         Class<ResultT> resultClass)
        Description copied from interface: CoreSync
        Finds a document in the collection.
        Specified by:
        findOne in interface CoreSync<DocumentT>
        Type Parameters:
        ResultT - the target document type of the iterable.
        Parameters:
        filter - the query filter
        resultClass - the class to decode each document into
        Returns:
        the resulting document
      • findOne

        public <ResultT> ResultT findOne​(Bson filter,
                                         RemoteFindOptions options,
                                         Class<ResultT> resultClass)
        Description copied from interface: CoreSync
        Finds a document in the collection.
        Specified by:
        findOne in interface CoreSync<DocumentT>
        Type Parameters:
        ResultT - the target document type of the iterable.
        Parameters:
        filter - the query filter
        options - A RemoteFindOptions struct
        resultClass - the class to decode each document into
        Returns:
        the resulting document
      • find

        public CoreSyncFindIterable<DocumentT> find​(Bson filter)
        Description copied from interface: CoreSync
        Finds all documents in the collection that have been synchronized with the remote.
        Specified by:
        find in interface CoreSync<DocumentT>
        Parameters:
        filter - the query filter
        Returns:
        the find iterable interface
      • find

        public <ResultT> CoreSyncFindIterable<ResultT> find​(Class<ResultT> resultClass)
        Description copied from interface: CoreSync
        Finds all documents in the collection that have been synchronized with the remote.
        Specified by:
        find in interface CoreSync<DocumentT>
        Type Parameters:
        ResultT - the target document type of the iterable.
        Parameters:
        resultClass - the class to decode each document into
        Returns:
        the find iterable interface
      • find

        public <ResultT> CoreSyncFindIterable<ResultT> find​(Bson filter,
                                                            Class<ResultT> resultClass)
        Finds all documents in the collection.
        Specified by:
        find in interface CoreSync<DocumentT>
        Type Parameters:
        ResultT - the target document type of the iterable.
        Parameters:
        filter - the query filter
        resultClass - the class to decode each document into
        Returns:
        the find iterable interface