Coverage Report - com.allanbank.mongodb.client.AbstractAsyncMongoCollection
 
Classes in this File Line Coverage Branch Coverage Complexity
AbstractAsyncMongoCollection
94%
257/271
N/A
1
 
 1  
 /*
 2  
  * #%L
 3  
  * AbstractAsyncMongoCollection.java - mongodb-async-driver - Allanbank Consulting, Inc.
 4  
  * %%
 5  
  * Copyright (C) 2011 - 2014 Allanbank Consulting, Inc.
 6  
  * %%
 7  
  * Licensed under the Apache License, Version 2.0 (the "License");
 8  
  * you may not use this file except in compliance with the License.
 9  
  * You may obtain a copy of the License at
 10  
  * 
 11  
  *      http://www.apache.org/licenses/LICENSE-2.0
 12  
  * 
 13  
  * Unless required by applicable law or agreed to in writing, software
 14  
  * distributed under the License is distributed on an "AS IS" BASIS,
 15  
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 16  
  * See the License for the specific language governing permissions and
 17  
  * limitations under the License.
 18  
  * #L%
 19  
  */
 20  
 package com.allanbank.mongodb.client;
 21  
 
 22  
 import java.util.Collection;
 23  
 
 24  
 import com.allanbank.mongodb.AsyncMongoCollection;
 25  
 import com.allanbank.mongodb.Callback;
 26  
 import com.allanbank.mongodb.Durability;
 27  
 import com.allanbank.mongodb.LambdaCallback;
 28  
 import com.allanbank.mongodb.ListenableFuture;
 29  
 import com.allanbank.mongodb.LockType;
 30  
 import com.allanbank.mongodb.MongoCollection;
 31  
 import com.allanbank.mongodb.MongoCursorControl;
 32  
 import com.allanbank.mongodb.MongoDatabase;
 33  
 import com.allanbank.mongodb.MongoDbException;
 34  
 import com.allanbank.mongodb.MongoIterator;
 35  
 import com.allanbank.mongodb.ReadPreference;
 36  
 import com.allanbank.mongodb.StreamCallback;
 37  
 import com.allanbank.mongodb.bson.Document;
 38  
 import com.allanbank.mongodb.bson.DocumentAssignable;
 39  
 import com.allanbank.mongodb.bson.Element;
 40  
 import com.allanbank.mongodb.bson.builder.BuilderFactory;
 41  
 import com.allanbank.mongodb.builder.Aggregate;
 42  
 import com.allanbank.mongodb.builder.BatchedWrite;
 43  
 import com.allanbank.mongodb.builder.ConditionBuilder;
 44  
 import com.allanbank.mongodb.builder.Count;
 45  
 import com.allanbank.mongodb.builder.Distinct;
 46  
 import com.allanbank.mongodb.builder.Find;
 47  
 import com.allanbank.mongodb.builder.FindAndModify;
 48  
 import com.allanbank.mongodb.builder.GroupBy;
 49  
 import com.allanbank.mongodb.builder.MapReduce;
 50  
 import com.allanbank.mongodb.builder.ParallelScan;
 51  
 
 52  
 /**
 53  
  * Helper class for forward all methods to the canonical version (which is
 54  
  * abstract in this class).
 55  
  * <p>
 56  
  * This class keeps the clutter in the derived class to a minimum and also deals
 57  
  * with the conversion of the asynchronous method invocations into synchronous
 58  
  * methods for those uses cases that do not require an asynchronous interface.
 59  
  * </p>
 60  
  * 
 61  
  * @api.no This class is <b>NOT</b> part of the drivers API. This class may be
 62  
  *         mutated in incompatible ways between any two releases of the driver.
 63  
  * @copyright 2011-2013, Allanbank Consulting, Inc., All Rights Reserved
 64  
  */
 65  
 public abstract class AbstractAsyncMongoCollection extends
 66  
         AbstractMongoOperations implements AsyncMongoCollection {
 67  
 
 68  
     /**
 69  
      * Create a new AbstractAsyncMongoCollection.
 70  
      * 
 71  
      * @param client
 72  
      *            The client for interacting with MongoDB.
 73  
      * @param database
 74  
      *            The database we interact with.
 75  
      * @param name
 76  
      *            The name of the collection we interact with.
 77  
      */
 78  
     public AbstractAsyncMongoCollection(final Client client,
 79  
             final MongoDatabase database, final String name) {
 80  275
         super(client, database, name);
 81  275
     }
 82  
 
 83  
     /**
 84  
      * {@inheritDoc}
 85  
      * <p>
 86  
      * Overridden to call the {@link #aggregateAsync(Callback, Aggregate)}.
 87  
      * </p>
 88  
      * 
 89  
      * @see #aggregateAsync(Callback, Aggregate)
 90  
      */
 91  
     @Override
 92  
     public ListenableFuture<MongoIterator<Document>> aggregateAsync(
 93  
             final Aggregate command) throws MongoDbException {
 94  
         final FutureCallback<MongoIterator<Document>> future;
 95  
 
 96  5
         future = new FutureCallback<MongoIterator<Document>>(getLockType());
 97  
 
 98  5
         aggregateAsync(future, command);
 99  
 
 100  5
         return future;
 101  
     }
 102  
 
 103  
     /**
 104  
      * {@inheritDoc}
 105  
      * <p>
 106  
      * Overridden to call the {@link #aggregateAsync(Aggregate)}.
 107  
      * </p>
 108  
      */
 109  
     @Override
 110  
     public ListenableFuture<MongoIterator<Document>> aggregateAsync(
 111  
             final Aggregate.Builder command) throws MongoDbException {
 112  4
         return aggregateAsync(command.build());
 113  
     }
 114  
 
 115  
     /**
 116  
      * {@inheritDoc}
 117  
      * <p>
 118  
      * Overridden to call the {@link #aggregateAsync(Callback, Aggregate)}.
 119  
      * </p>
 120  
      */
 121  
     @Override
 122  
     public void aggregateAsync(final Callback<MongoIterator<Document>> results,
 123  
             final Aggregate.Builder command) throws MongoDbException {
 124  2
         aggregateAsync(results, command.build());
 125  2
     }
 126  
 
 127  
     /**
 128  
      * {@inheritDoc}
 129  
      * <p>
 130  
      * Overridden to call the {@link #aggregateAsync(Callback, Aggregate)}
 131  
      * method with an adapter for the {@link LambdaCallback}.
 132  
      * </p>
 133  
      */
 134  
     @Override
 135  
     public void aggregateAsync(
 136  
             final LambdaCallback<MongoIterator<Document>> results,
 137  
             final Aggregate command) throws MongoDbException {
 138  1
         aggregateAsync(new LambdaCallbackAdapter<MongoIterator<Document>>(
 139  
                 results), command);
 140  1
     }
 141  
 
 142  
     /**
 143  
      * {@inheritDoc}
 144  
      * <p>
 145  
      * Overridden to call the
 146  
      * {@link #aggregateAsync(Callback, Aggregate.Builder)} method with an
 147  
      * adapter for the {@link LambdaCallback}.
 148  
      * </p>
 149  
      */
 150  
     @Override
 151  
     public void aggregateAsync(
 152  
             final LambdaCallback<MongoIterator<Document>> results,
 153  
             final Aggregate.Builder command) throws MongoDbException {
 154  1
         aggregateAsync(new LambdaCallbackAdapter<MongoIterator<Document>>(
 155  
                 results), command);
 156  1
     }
 157  
 
 158  
     /**
 159  
      * {@inheritDoc}
 160  
      * <p>
 161  
      * Overridden to call the
 162  
      * {@link #countAsync(DocumentAssignable,ReadPreference)} method with
 163  
      * {@link #getReadPreference()} as the <tt>readPreference</tt> argument and
 164  
      * an empty {@code query} document.
 165  
      * </p>
 166  
      */
 167  
     @Override
 168  
     public ListenableFuture<Long> countAsync() throws MongoDbException {
 169  1
         return countAsync(BuilderFactory.start(), getReadPreference());
 170  
     }
 171  
 
 172  
     /**
 173  
      * {@inheritDoc}
 174  
      * <p>
 175  
      * Overridden to call the
 176  
      * {@link #countAsync(Callback,DocumentAssignable,ReadPreference)} method
 177  
      * with {@link #getReadPreference()} as the <tt>readPreference</tt> argument
 178  
      * and an empty {@code query} document.
 179  
      * </p>
 180  
      */
 181  
     @Override
 182  
     public void countAsync(final Callback<Long> results)
 183  
             throws MongoDbException {
 184  2
         countAsync(results, BuilderFactory.start(), getReadPreference());
 185  2
     }
 186  
 
 187  
     /**
 188  
      * {@inheritDoc}
 189  
      * <p>
 190  
      * Overridden to call the {@link #countAsync(Callback, Count)
 191  
      * countAsync(results, count.build())}.
 192  
      * </p>
 193  
      */
 194  
     @Override
 195  
     public void countAsync(final Callback<Long> results,
 196  
             final Count.Builder count) throws MongoDbException {
 197  1
         countAsync(results, count.build());
 198  1
     }
 199  
 
 200  
     /**
 201  
      * {@inheritDoc}
 202  
      * <p>
 203  
      * Overridden to call the
 204  
      * {@link #countAsync(Callback, DocumentAssignable, ReadPreference)} method
 205  
      * with {@link #getReadPreference()} as the <tt>readPreference</tt>
 206  
      * argument.
 207  
      * </p>
 208  
      */
 209  
     @Override
 210  
     public void countAsync(final Callback<Long> results,
 211  
             final DocumentAssignable query) throws MongoDbException {
 212  2
         countAsync(results, query, getReadPreference());
 213  2
     }
 214  
 
 215  
     /**
 216  
      * {@inheritDoc}
 217  
      * <p>
 218  
      * Overridden to call the {@link #countAsync(Callback, Count)} method with
 219  
      * the query and read preferences set.
 220  
      * </p>
 221  
      */
 222  
     @Override
 223  
     public void countAsync(final Callback<Long> results,
 224  
             final DocumentAssignable query, final ReadPreference readPreference)
 225  
             throws MongoDbException {
 226  21
         countAsync(results,
 227  
                 Count.builder().query(query).readPreference(readPreference)
 228  
                         .build());
 229  21
     }
 230  
 
 231  
     /**
 232  
      * {@inheritDoc}
 233  
      * <p>
 234  
      * Overridden to call the
 235  
      * {@link #countAsync(Callback,DocumentAssignable,ReadPreference)} method
 236  
      * with an empty {@code query} document.
 237  
      * </p>
 238  
      */
 239  
     @Override
 240  
     public void countAsync(final Callback<Long> results,
 241  
             final ReadPreference readPreference) throws MongoDbException {
 242  2
         countAsync(results, BuilderFactory.start(), readPreference);
 243  2
     }
 244  
 
 245  
     /**
 246  
      * {@inheritDoc}
 247  
      * <p>
 248  
      * Overridden to call the {@link #countAsync(Callback, Count)}.
 249  
      * </p>
 250  
      * On an error counting the documents.
 251  
      */
 252  
     @Override
 253  
     public ListenableFuture<Long> countAsync(final Count count)
 254  
             throws MongoDbException {
 255  1
         final FutureCallback<Long> future = new FutureCallback<Long>(
 256  
                 getLockType());
 257  
 
 258  1
         countAsync(future, count);
 259  
 
 260  1
         return future;
 261  
     }
 262  
 
 263  
     /**
 264  
      * {@inheritDoc}
 265  
      * <p>
 266  
      * Overridden to call the {@link #countAsync(Count)
 267  
      * countAsync(count.build())}.
 268  
      * </p>
 269  
      */
 270  
     @Override
 271  
     public ListenableFuture<Long> countAsync(final Count.Builder count)
 272  
             throws MongoDbException {
 273  1
         return countAsync(count.build());
 274  
     }
 275  
 
 276  
     /**
 277  
      * {@inheritDoc}
 278  
      * <p>
 279  
      * Overridden to call the
 280  
      * {@link #countAsync(Callback, DocumentAssignable, ReadPreference)} method
 281  
      * with {@link #getReadPreference()} as the <tt>readPreference</tt>
 282  
      * argument.
 283  
      * </p>
 284  
      * 
 285  
      * @param query
 286  
      *            The query document.
 287  
      * @return A future that will be updated with the number of matching
 288  
      *         documents.
 289  
      * @throws MongoDbException
 290  
      *             On an error finding the documents.
 291  
      */
 292  
     @Override
 293  
     public ListenableFuture<Long> countAsync(final DocumentAssignable query)
 294  
             throws MongoDbException {
 295  1
         final FutureCallback<Long> future = new FutureCallback<Long>(
 296  
                 getLockType());
 297  
 
 298  1
         countAsync(future, query, getReadPreference());
 299  
 
 300  1
         return future;
 301  
     }
 302  
 
 303  
     /**
 304  
      * {@inheritDoc}
 305  
      * <p>
 306  
      * Overridden to call the
 307  
      * {@link #countAsync(Callback, DocumentAssignable, ReadPreference)} method.
 308  
      * </p>
 309  
      */
 310  
     @Override
 311  
     public ListenableFuture<Long> countAsync(final DocumentAssignable query,
 312  
             final ReadPreference readPreference) throws MongoDbException {
 313  12
         final FutureCallback<Long> future = new FutureCallback<Long>(
 314  
                 getLockType());
 315  
 
 316  12
         countAsync(future, query, readPreference);
 317  
 
 318  12
         return future;
 319  
     }
 320  
 
 321  
     /**
 322  
      * {@inheritDoc}
 323  
      * <p>
 324  
      * Overridden to call the {@link #countAsync(Callback)} method with an
 325  
      * adapter for the {@link LambdaCallback}.
 326  
      * </p>
 327  
      */
 328  
     @Override
 329  
     public void countAsync(final LambdaCallback<Long> results)
 330  
             throws MongoDbException {
 331  1
         countAsync(new LambdaCallbackAdapter<Long>(results));
 332  1
     }
 333  
 
 334  
     /**
 335  
      * {@inheritDoc}
 336  
      * <p>
 337  
      * Overridden to call the {@link #countAsync(Callback, Count)} method with
 338  
      * an adapter for the {@link LambdaCallback}.
 339  
      * </p>
 340  
      */
 341  
     @Override
 342  
     public void countAsync(final LambdaCallback<Long> results, final Count count)
 343  
             throws MongoDbException {
 344  1
         countAsync(new LambdaCallbackAdapter<Long>(results), count);
 345  1
     }
 346  
 
 347  
     /**
 348  
      * {@inheritDoc}
 349  
      * <p>
 350  
      * Overridden to call the {@link #countAsync(Callback, Count.Builder)}
 351  
      * method with an adapter for the {@link LambdaCallback}.
 352  
      * </p>
 353  
      */
 354  
     @Override
 355  
     public void countAsync(final LambdaCallback<Long> results,
 356  
             final Count.Builder count) throws MongoDbException {
 357  1
         countAsync(new LambdaCallbackAdapter<Long>(results), count);
 358  1
     }
 359  
 
 360  
     /**
 361  
      * {@inheritDoc}
 362  
      * <p>
 363  
      * Overridden to call the {@link #countAsync(Callback, DocumentAssignable)}
 364  
      * method with an adapter for the {@link LambdaCallback}.
 365  
      * </p>
 366  
      */
 367  
     @Override
 368  
     public void countAsync(final LambdaCallback<Long> results,
 369  
             final DocumentAssignable query) throws MongoDbException {
 370  1
         countAsync(new LambdaCallbackAdapter<Long>(results), query);
 371  
 
 372  1
     }
 373  
 
 374  
     /**
 375  
      * {@inheritDoc}
 376  
      * <p>
 377  
      * Overridden to call the
 378  
      * {@link #countAsync(Callback, DocumentAssignable, ReadPreference)} method
 379  
      * with an adapter for the {@link LambdaCallback}.
 380  
      * </p>
 381  
      */
 382  
     @Override
 383  
     public void countAsync(final LambdaCallback<Long> results,
 384  
             final DocumentAssignable query, final ReadPreference readPreference)
 385  
             throws MongoDbException {
 386  1
         countAsync(new LambdaCallbackAdapter<Long>(results), query,
 387  
                 readPreference);
 388  1
     }
 389  
 
 390  
     /**
 391  
      * {@inheritDoc}
 392  
      * <p>
 393  
      * Overridden to call the {@link #countAsync(Callback, ReadPreference)}
 394  
      * method with an adapter for the {@link LambdaCallback}.
 395  
      * </p>
 396  
      */
 397  
     @Override
 398  
     public void countAsync(final LambdaCallback<Long> results,
 399  
             final ReadPreference readPreference) throws MongoDbException {
 400  1
         countAsync(new LambdaCallbackAdapter<Long>(results), readPreference);
 401  1
     }
 402  
 
 403  
     /**
 404  
      * {@inheritDoc}
 405  
      * <p>
 406  
      * Overridden to call the
 407  
      * {@link #countAsync(DocumentAssignable,ReadPreference)} method with an
 408  
      * empty {@code query} document.
 409  
      * </p>
 410  
      */
 411  
     @Override
 412  
     public ListenableFuture<Long> countAsync(final ReadPreference readPreference)
 413  
             throws MongoDbException {
 414  1
         return countAsync(BuilderFactory.start(), readPreference);
 415  
     }
 416  
 
 417  
     /**
 418  
      * {@inheritDoc}
 419  
      * <p>
 420  
      * Overridden to call the
 421  
      * {@link #deleteAsync(Callback, DocumentAssignable, boolean, Durability)}
 422  
      * method with false as the <tt>singleDelete</tt> argument and the
 423  
      * {@link #getDurability() default durability}.
 424  
      * </p>
 425  
      * 
 426  
      * @see #deleteAsync(Callback, DocumentAssignable, boolean, Durability)
 427  
      */
 428  
     @Override
 429  
     public void deleteAsync(final Callback<Long> results,
 430  
             final DocumentAssignable query) throws MongoDbException {
 431  3
         deleteAsync(results, query, DELETE_SINGLE_DELETE_DEFAULT,
 432  
                 getDurability());
 433  3
     }
 434  
 
 435  
     /**
 436  
      * {@inheritDoc}
 437  
      * <p>
 438  
      * Overridden to call the
 439  
      * {@link #deleteAsync(Callback, DocumentAssignable, boolean, Durability)}
 440  
      * method with the {@link #getDurability() default durability}.
 441  
      * </p>
 442  
      * 
 443  
      * @see MongoCollection#deleteAsync(Callback, DocumentAssignable)
 444  
      */
 445  
     @Override
 446  
     public void deleteAsync(final Callback<Long> results,
 447  
             final DocumentAssignable query, final boolean singleDelete)
 448  
             throws MongoDbException {
 449  2
         deleteAsync(results, query, singleDelete, getDurability());
 450  2
     }
 451  
 
 452  
     /**
 453  
      * {@inheritDoc}
 454  
      * <p>
 455  
      * Overridden to call the
 456  
      * {@link #deleteAsync(Callback, DocumentAssignable, boolean, Durability)}
 457  
      * method with false as the <tt>singleDelete</tt> argument.
 458  
      * </p>
 459  
      * 
 460  
      * @see MongoCollection#deleteAsync(Callback, DocumentAssignable, boolean)
 461  
      */
 462  
     @Override
 463  
     public void deleteAsync(final Callback<Long> results,
 464  
             final DocumentAssignable query, final Durability durability)
 465  
             throws MongoDbException {
 466  2
         deleteAsync(results, query, DELETE_SINGLE_DELETE_DEFAULT, durability);
 467  2
     }
 468  
 
 469  
     /**
 470  
      * {@inheritDoc}
 471  
      * <p>
 472  
      * Overridden to call the
 473  
      * {@link #deleteAsync(Callback, DocumentAssignable, boolean, Durability)}
 474  
      * method with false as the <tt>singleDelete</tt> argument and the
 475  
      * {@link #getDurability() default durability}.
 476  
      * </p>
 477  
      * 
 478  
      * @see MongoCollection#deleteAsync(Callback, DocumentAssignable)
 479  
      */
 480  
     @Override
 481  
     public ListenableFuture<Long> deleteAsync(final DocumentAssignable query)
 482  
             throws MongoDbException {
 483  14
         final FutureCallback<Long> future = new FutureCallback<Long>(
 484  
                 getLockType());
 485  
 
 486  14
         deleteAsync(future, query, DELETE_SINGLE_DELETE_DEFAULT,
 487  
                 getDurability());
 488  
 
 489  14
         return future;
 490  
     }
 491  
 
 492  
     /**
 493  
      * {@inheritDoc}
 494  
      * <p>
 495  
      * Overridden to call the
 496  
      * {@link #deleteAsync(Callback, DocumentAssignable, boolean, Durability)}
 497  
      * method with the {@link #getDurability() default durability}.
 498  
      * </p>
 499  
      * 
 500  
      * @see MongoCollection#deleteAsync(Callback, DocumentAssignable)
 501  
      */
 502  
     @Override
 503  
     public ListenableFuture<Long> deleteAsync(final DocumentAssignable query,
 504  
             final boolean singleDelete) throws MongoDbException {
 505  1
         final FutureCallback<Long> future = new FutureCallback<Long>(
 506  
                 getLockType());
 507  
 
 508  1
         deleteAsync(future, query, singleDelete, getDurability());
 509  
 
 510  1
         return future;
 511  
     }
 512  
 
 513  
     /**
 514  
      * {@inheritDoc}
 515  
      * <p>
 516  
      * Overridden to call the {@link #deleteAsync(Callback, DocumentAssignable)}
 517  
      * method.
 518  
      * </p>
 519  
      * 
 520  
      * @see MongoCollection#deleteAsync(Callback, DocumentAssignable)
 521  
      */
 522  
     @Override
 523  
     public ListenableFuture<Long> deleteAsync(final DocumentAssignable query,
 524  
             final boolean singleDelete, final Durability durability)
 525  
             throws MongoDbException {
 526  6
         final FutureCallback<Long> future = new FutureCallback<Long>(
 527  
                 getLockType());
 528  
 
 529  6
         deleteAsync(future, query, singleDelete, durability);
 530  
 
 531  6
         return future;
 532  
     }
 533  
 
 534  
     /**
 535  
      * {@inheritDoc}
 536  
      * <p>
 537  
      * Overridden to call the {@link #deleteAsync(Callback, DocumentAssignable)}
 538  
      * method with false as the <tt>singleDelete</tt> argument.
 539  
      * </p>
 540  
      * 
 541  
      * @see MongoCollection#deleteAsync(Callback, DocumentAssignable)
 542  
      */
 543  
     @Override
 544  
     public ListenableFuture<Long> deleteAsync(final DocumentAssignable query,
 545  
             final Durability durability) throws MongoDbException {
 546  1
         final FutureCallback<Long> future = new FutureCallback<Long>(
 547  
                 getLockType());
 548  
 
 549  1
         deleteAsync(future, query, DELETE_SINGLE_DELETE_DEFAULT, durability);
 550  
 
 551  1
         return future;
 552  
     }
 553  
 
 554  
     /**
 555  
      * {@inheritDoc}
 556  
      * <p>
 557  
      * Overridden to call the {@link #deleteAsync(Callback, DocumentAssignable)}
 558  
      * method with an adapter for the {@link LambdaCallback}.
 559  
      * </p>
 560  
      */
 561  
     @Override
 562  
     public void deleteAsync(final LambdaCallback<Long> results,
 563  
             final DocumentAssignable query) throws MongoDbException {
 564  1
         deleteAsync(new LambdaCallbackAdapter<Long>(results), query);
 565  1
     }
 566  
 
 567  
     /**
 568  
      * {@inheritDoc}
 569  
      * <p>
 570  
      * Overridden to call the
 571  
      * {@link #deleteAsync(Callback, DocumentAssignable, boolean)} method with
 572  
      * an adapter for the {@link LambdaCallback}.
 573  
      * </p>
 574  
      */
 575  
     @Override
 576  
     public void deleteAsync(final LambdaCallback<Long> results,
 577  
             final DocumentAssignable query, final boolean singleDelete)
 578  
             throws MongoDbException {
 579  1
         deleteAsync(new LambdaCallbackAdapter<Long>(results), query,
 580  
                 singleDelete);
 581  1
     }
 582  
 
 583  
     /**
 584  
      * {@inheritDoc}
 585  
      * <p>
 586  
      * Overridden to call the
 587  
      * {@link #deleteAsync(Callback, DocumentAssignable, boolean, Durability)}
 588  
      * method with an adapter for the {@link LambdaCallback}.
 589  
      * </p>
 590  
      */
 591  
     @Override
 592  
     public void deleteAsync(final LambdaCallback<Long> results,
 593  
             final DocumentAssignable query, final boolean singleDelete,
 594  
             final Durability durability) throws MongoDbException {
 595  1
         deleteAsync(new LambdaCallbackAdapter<Long>(results), query,
 596  
                 singleDelete, durability);
 597  1
     }
 598  
 
 599  
     /**
 600  
      * {@inheritDoc}
 601  
      * <p>
 602  
      * Overridden to call the
 603  
      * {@link #deleteAsync(Callback, DocumentAssignable, Durability)} method
 604  
      * with an adapter for the {@link LambdaCallback}.
 605  
      * </p>
 606  
      */
 607  
     @Override
 608  
     public void deleteAsync(final LambdaCallback<Long> results,
 609  
             final DocumentAssignable query, final Durability durability)
 610  
             throws MongoDbException {
 611  1
         deleteAsync(new LambdaCallbackAdapter<Long>(results), query, durability);
 612  1
     }
 613  
 
 614  
     /**
 615  
      * {@inheritDoc}
 616  
      * <p>
 617  
      * Overridden to call the {@link #distinctAsync(Callback, Distinct)}.
 618  
      * </p>
 619  
      */
 620  
     @Override
 621  
     public void distinctAsync(final Callback<MongoIterator<Element>> results,
 622  
             final Distinct.Builder command) throws MongoDbException {
 623  5
         distinctAsync(results, command.build());
 624  5
     }
 625  
 
 626  
     /**
 627  
      * {@inheritDoc}
 628  
      * <p>
 629  
      * Overridden to call the {@link #distinctAsync(Callback, Distinct)}.
 630  
      * </p>
 631  
      */
 632  
     @Override
 633  
     public ListenableFuture<MongoIterator<Element>> distinctAsync(
 634  
             final Distinct command) throws MongoDbException {
 635  3
         final FutureCallback<MongoIterator<Element>> future = new FutureCallback<MongoIterator<Element>>(
 636  
                 getLockType());
 637  
 
 638  3
         distinctAsync(future, command);
 639  
 
 640  3
         return future;
 641  
     }
 642  
 
 643  
     /**
 644  
      * {@inheritDoc}
 645  
      * <p>
 646  
      * Overridden to call the {@link #distinctAsync(Distinct)}.
 647  
      * </p>
 648  
      */
 649  
     @Override
 650  
     public ListenableFuture<MongoIterator<Element>> distinctAsync(
 651  
             final Distinct.Builder command) throws MongoDbException {
 652  2
         return distinctAsync(command.build());
 653  
     }
 654  
 
 655  
     /**
 656  
      * {@inheritDoc}
 657  
      * <p>
 658  
      * Overridden to call the {@link #distinctAsync(Callback, Distinct)} method
 659  
      * with an adapter for the {@link LambdaCallback}.
 660  
      * </p>
 661  
      */
 662  
     @Override
 663  
     public void distinctAsync(
 664  
             final LambdaCallback<MongoIterator<Element>> results,
 665  
             final Distinct command) throws MongoDbException {
 666  1
         distinctAsync(
 667  
                 new LambdaCallbackAdapter<MongoIterator<Element>>(results),
 668  
                 command);
 669  1
     }
 670  
 
 671  
     /**
 672  
      * {@inheritDoc}
 673  
      * <p>
 674  
      * Overridden to call the {@link #distinctAsync(Callback, Distinct.Builder)}
 675  
      * method with an adapter for the {@link LambdaCallback}.
 676  
      * </p>
 677  
      */
 678  
     @Override
 679  
     public void distinctAsync(
 680  
             final LambdaCallback<MongoIterator<Element>> results,
 681  
             final Distinct.Builder command) throws MongoDbException {
 682  1
         distinctAsync(
 683  
                 new LambdaCallbackAdapter<MongoIterator<Element>>(results),
 684  
                 command);
 685  1
     }
 686  
 
 687  
     /**
 688  
      * {@inheritDoc}
 689  
      * <p>
 690  
      * Overridden to call the {@link #explainAsync(Callback,Aggregate)} method.
 691  
      * </p>
 692  
      */
 693  
     @Override
 694  
     public ListenableFuture<Document> explainAsync(final Aggregate aggregation)
 695  
             throws MongoDbException {
 696  1
         final FutureCallback<Document> future = new FutureCallback<Document>(
 697  
                 getLockType());
 698  
 
 699  1
         explainAsync(future, aggregation);
 700  
 
 701  1
         return future;
 702  
 
 703  
     }
 704  
 
 705  
     /**
 706  
      * {@inheritDoc}
 707  
      * <p>
 708  
      * Overridden to call the {@link #explainAsync(Callback,Aggregate)} method.
 709  
      * </p>
 710  
      */
 711  
     @Override
 712  
     public ListenableFuture<Document> explainAsync(
 713  
             final Aggregate.Builder aggregation) throws MongoDbException {
 714  1
         final FutureCallback<Document> future = new FutureCallback<Document>(
 715  
                 getLockType());
 716  
 
 717  1
         explainAsync(future, aggregation.build());
 718  
 
 719  1
         return future;
 720  
     }
 721  
 
 722  
     /**
 723  
      * {@inheritDoc}
 724  
      * <p>
 725  
      * Overridden to call the {@link #explainAsync(Callback,Aggregate)} method.
 726  
      * </p>
 727  
      */
 728  
     @Override
 729  
     public void explainAsync(final Callback<Document> results,
 730  
             final Aggregate.Builder aggregation) throws MongoDbException {
 731  2
         explainAsync(results, aggregation.build());
 732  2
     }
 733  
 
 734  
     /**
 735  
      * {@inheritDoc}
 736  
      * <p>
 737  
      * Overridden to call the {@link #explainAsync(Callback,Find)} method.
 738  
      * </p>
 739  
      */
 740  
     @Override
 741  
     public void explainAsync(final Callback<Document> results,
 742  
             final Find.Builder query) throws MongoDbException {
 743  2
         explainAsync(results, query.build());
 744  2
     }
 745  
 
 746  
     /**
 747  
      * {@inheritDoc}
 748  
      * <p>
 749  
      * Overridden to call the {@link #explainAsync(Callback,Find)} method.
 750  
      * </p>
 751  
      * 
 752  
      * @see #explainAsync(Callback,Find)
 753  
      */
 754  
     @Override
 755  
     public ListenableFuture<Document> explainAsync(final Find query)
 756  
             throws MongoDbException {
 757  4
         final FutureCallback<Document> future = new FutureCallback<Document>(
 758  
                 getLockType());
 759  
 
 760  4
         explainAsync(future, query);
 761  
 
 762  4
         return future;
 763  
     }
 764  
 
 765  
     /**
 766  
      * {@inheritDoc}
 767  
      * <p>
 768  
      * Overridden to call the {@link #explainAsync(Find)} method.
 769  
      * </p>
 770  
      */
 771  
     @Override
 772  
     public ListenableFuture<Document> explainAsync(final Find.Builder query)
 773  
             throws MongoDbException {
 774  2
         return explainAsync(query.build());
 775  
     }
 776  
 
 777  
     /**
 778  
      * {@inheritDoc}
 779  
      * <p>
 780  
      * Overridden to call the {@link #explainAsync(Callback, Aggregate)} method
 781  
      * with an adapter for the {@link LambdaCallback}.
 782  
      * </p>
 783  
      */
 784  
     @Override
 785  
     public void explainAsync(final LambdaCallback<Document> results,
 786  
             final Aggregate aggregation) throws MongoDbException {
 787  1
         explainAsync(new LambdaCallbackAdapter<Document>(results), aggregation);
 788  1
     }
 789  
 
 790  
     /**
 791  
      * {@inheritDoc}
 792  
      * <p>
 793  
      * Overridden to call the {@link #explainAsync(Callback, Aggregate.Builder)}
 794  
      * method with an adapter for the {@link LambdaCallback}.
 795  
      * </p>
 796  
      */
 797  
     @Override
 798  
     public void explainAsync(final LambdaCallback<Document> results,
 799  
             final Aggregate.Builder aggregation) throws MongoDbException {
 800  1
         explainAsync(new LambdaCallbackAdapter<Document>(results), aggregation);
 801  1
     }
 802  
 
 803  
     /**
 804  
      * {@inheritDoc}
 805  
      * <p>
 806  
      * Overridden to call the {@link #explainAsync(Callback, Find)} method with
 807  
      * an adapter for the {@link LambdaCallback}.
 808  
      * </p>
 809  
      */
 810  
     @Override
 811  
     public void explainAsync(final LambdaCallback<Document> results,
 812  
             final Find query) throws MongoDbException {
 813  1
         explainAsync(new LambdaCallbackAdapter<Document>(results), query);
 814  1
     }
 815  
 
 816  
     /**
 817  
      * {@inheritDoc}
 818  
      * <p>
 819  
      * Overridden to call the {@link #explainAsync(Callback, Find.Builder)}
 820  
      * method with an adapter for the {@link LambdaCallback}.
 821  
      * </p>
 822  
      */
 823  
     @Override
 824  
     public void explainAsync(final LambdaCallback<Document> results,
 825  
             final Find.Builder query) throws MongoDbException {
 826  1
         explainAsync(new LambdaCallbackAdapter<Document>(results), query);
 827  1
     }
 828  
 
 829  
     /**
 830  
      * {@inheritDoc}
 831  
      * <p>
 832  
      * Overridden to call the
 833  
      * {@link #findAndModifyAsync(Callback,FindAndModify)}.
 834  
      * </p>
 835  
      */
 836  
     @Override
 837  
     public void findAndModifyAsync(final Callback<Document> results,
 838  
             final FindAndModify.Builder command) throws MongoDbException {
 839  2
         findAndModifyAsync(results, command.build());
 840  2
     }
 841  
 
 842  
     /**
 843  
      * {@inheritDoc}
 844  
      * <p>
 845  
      * Overridden to call the
 846  
      * {@link #findAndModifyAsync(Callback, FindAndModify)}.
 847  
      * </p>
 848  
      * 
 849  
      * @see #findAndModifyAsync(Callback, FindAndModify)
 850  
      */
 851  
     @Override
 852  
     public ListenableFuture<Document> findAndModifyAsync(
 853  
             final FindAndModify command) throws MongoDbException {
 854  8
         final FutureCallback<Document> future = new FutureCallback<Document>(
 855  
                 getLockType());
 856  
 
 857  8
         findAndModifyAsync(future, command);
 858  
 
 859  8
         return future;
 860  
     }
 861  
 
 862  
     /**
 863  
      * {@inheritDoc}
 864  
      * <p>
 865  
      * Overridden to call the {@link #findAndModifyAsync(FindAndModify)}.
 866  
      * </p>
 867  
      */
 868  
     @Override
 869  
     public ListenableFuture<Document> findAndModifyAsync(
 870  
             final FindAndModify.Builder command) throws MongoDbException {
 871  1
         return findAndModifyAsync(command.build());
 872  
     }
 873  
 
 874  
     /**
 875  
      * {@inheritDoc}
 876  
      * <p>
 877  
      * Overridden to call the
 878  
      * {@link #findAndModifyAsync(Callback, FindAndModify)} method with an
 879  
      * adapter for the {@link LambdaCallback}.
 880  
      * </p>
 881  
      */
 882  
     @Override
 883  
     public void findAndModifyAsync(final LambdaCallback<Document> results,
 884  
             final FindAndModify command) throws MongoDbException {
 885  0
         findAndModifyAsync(new LambdaCallbackAdapter<Document>(results),
 886  
                 command);
 887  0
     }
 888  
 
 889  
     /**
 890  
      * {@inheritDoc}
 891  
      * <p>
 892  
      * Overridden to call the
 893  
      * {@link #findAndModifyAsync(Callback, FindAndModify.Builder)} method with
 894  
      * an adapter for the {@link LambdaCallback}.
 895  
      * </p>
 896  
      */
 897  
     @Override
 898  
     public void findAndModifyAsync(final LambdaCallback<Document> results,
 899  
             final FindAndModify.Builder command) throws MongoDbException {
 900  1
         findAndModifyAsync(new LambdaCallbackAdapter<Document>(results),
 901  
                 command);
 902  1
     }
 903  
 
 904  
     /**
 905  
      * {@inheritDoc}
 906  
      * <p>
 907  
      * Overridden to call the {@link #findAsync(Callback, Find)}.
 908  
      * </p>
 909  
      * 
 910  
      * @see #findAsync(Callback, DocumentAssignable)
 911  
      */
 912  
     @Override
 913  
     public void findAsync(final Callback<MongoIterator<Document>> results,
 914  
             final DocumentAssignable query) throws MongoDbException {
 915  4
         findAsync(results, new Find.Builder(query).build());
 916  4
     }
 917  
 
 918  
     /**
 919  
      * {@inheritDoc}
 920  
      * <p>
 921  
      * Overridden to call the {@link #findAsync(Callback,Find)} method.
 922  
      * </p>
 923  
      */
 924  
     @Override
 925  
     public void findAsync(final Callback<MongoIterator<Document>> results,
 926  
             final Find.Builder query) throws MongoDbException {
 927  2
         findAsync(results, query.build());
 928  2
     }
 929  
 
 930  
     /**
 931  
      * {@inheritDoc}
 932  
      * <p>
 933  
      * Overridden to call the {@link #findAsync(Callback, DocumentAssignable)}.
 934  
      * </p>
 935  
      * 
 936  
      * @see #findAsync(Callback, DocumentAssignable)
 937  
      */
 938  
     @Override
 939  
     public ListenableFuture<MongoIterator<Document>> findAsync(
 940  
             final DocumentAssignable query) throws MongoDbException {
 941  2
         final FutureCallback<MongoIterator<Document>> future = new FutureCallback<MongoIterator<Document>>(
 942  
                 getLockType());
 943  
 
 944  2
         findAsync(future, query);
 945  
 
 946  2
         return future;
 947  
     }
 948  
 
 949  
     /**
 950  
      * {@inheritDoc}
 951  
      * <p>
 952  
      * Overridden to call the {@link #findAsync(Callback, Find)}.
 953  
      * </p>
 954  
      * 
 955  
      * @see #findAsync(Callback, Find)
 956  
      */
 957  
     @Override
 958  
     public ListenableFuture<MongoIterator<Document>> findAsync(final Find query)
 959  
             throws MongoDbException {
 960  6
         final FutureCallback<MongoIterator<Document>> future = new FutureCallback<MongoIterator<Document>>(
 961  
                 getLockType());
 962  
 
 963  6
         findAsync(future, query);
 964  
 
 965  6
         return future;
 966  
     }
 967  
 
 968  
     /**
 969  
      * {@inheritDoc}
 970  
      * <p>
 971  
      * Overridden to call the {@link #findAsync(Find)} method.
 972  
      * </p>
 973  
      */
 974  
     @Override
 975  
     public ListenableFuture<MongoIterator<Document>> findAsync(
 976  
             final Find.Builder query) throws MongoDbException {
 977  4
         return findAsync(query.build());
 978  
     }
 979  
 
 980  
     /**
 981  
      * {@inheritDoc}
 982  
      * <p>
 983  
      * Overridden to call the {@link #findAsync(Callback, DocumentAssignable)}
 984  
      * method with an adapter for the {@link LambdaCallback}.
 985  
      * </p>
 986  
      */
 987  
     @Override
 988  
     public void findAsync(
 989  
             final LambdaCallback<MongoIterator<Document>> results,
 990  
             final DocumentAssignable query) throws MongoDbException {
 991  1
         findAsync(new LambdaCallbackAdapter<MongoIterator<Document>>(results),
 992  
                 query);
 993  1
     }
 994  
 
 995  
     /**
 996  
      * {@inheritDoc}
 997  
      * <p>
 998  
      * Overridden to call the {@link #findAsync(Callback, Find)} method with an
 999  
      * adapter for the {@link LambdaCallback}.
 1000  
      * </p>
 1001  
      */
 1002  
     @Override
 1003  
     public void findAsync(
 1004  
             final LambdaCallback<MongoIterator<Document>> results,
 1005  
             final Find query) throws MongoDbException {
 1006  1
         findAsync(new LambdaCallbackAdapter<MongoIterator<Document>>(results),
 1007  
                 query);
 1008  1
     }
 1009  
 
 1010  
     /**
 1011  
      * {@inheritDoc}
 1012  
      * <p>
 1013  
      * Overridden to call the {@link #findAsync(Callback, Find.Builder)} method
 1014  
      * with an adapter for the {@link LambdaCallback}.
 1015  
      * </p>
 1016  
      */
 1017  
     @Override
 1018  
     public void findAsync(
 1019  
             final LambdaCallback<MongoIterator<Document>> results,
 1020  
             final Find.Builder query) throws MongoDbException {
 1021  1
         findAsync(new LambdaCallbackAdapter<MongoIterator<Document>>(results),
 1022  
                 query);
 1023  1
     }
 1024  
 
 1025  
     /**
 1026  
      * {@inheritDoc}
 1027  
      * <p>
 1028  
      * Overridden to call the {@link #findOneAsync(Callback, Find)}.
 1029  
      * </p>
 1030  
      * 
 1031  
      * @see #findOneAsync(Callback, Find)
 1032  
      */
 1033  
     @Override
 1034  
     public void findOneAsync(final Callback<Document> results,
 1035  
             final DocumentAssignable query) throws MongoDbException {
 1036  17
         findOneAsync(results, new Find.Builder(query).build());
 1037  17
     }
 1038  
 
 1039  
     /**
 1040  
      * {@inheritDoc}
 1041  
      * <p>
 1042  
      * Overridden to call the {@link #findOneAsync(Callback, Find)} method.
 1043  
      * </p>
 1044  
      */
 1045  
     @Override
 1046  
     public void findOneAsync(final Callback<Document> results,
 1047  
             final Find.Builder query) throws MongoDbException {
 1048  2
         findOneAsync(results, query.build());
 1049  2
     }
 1050  
 
 1051  
     /**
 1052  
      * {@inheritDoc}
 1053  
      * <p>
 1054  
      * Overridden to call the
 1055  
      * {@link #findOneAsync(Callback, DocumentAssignable)}.
 1056  
      * </p>
 1057  
      * 
 1058  
      * @see #findOneAsync(Callback, DocumentAssignable)
 1059  
      */
 1060  
     @Override
 1061  
     public ListenableFuture<Document> findOneAsync(
 1062  
             final DocumentAssignable query) throws MongoDbException {
 1063  15
         final FutureCallback<Document> future = new FutureCallback<Document>(
 1064  
                 getLockType());
 1065  
 
 1066  15
         findOneAsync(future, query);
 1067  
 
 1068  15
         return future;
 1069  
     }
 1070  
 
 1071  
     /**
 1072  
      * {@inheritDoc}
 1073  
      * <p>
 1074  
      * Overridden to call the {@link #findOneAsync(Callback, Find)}.
 1075  
      * </p>
 1076  
      * 
 1077  
      * @see #findOneAsync(Callback, Find)
 1078  
      */
 1079  
     @Override
 1080  
     public ListenableFuture<Document> findOneAsync(final Find query)
 1081  
             throws MongoDbException {
 1082  4
         final FutureCallback<Document> future = new FutureCallback<Document>(
 1083  
                 getLockType());
 1084  
 
 1085  4
         findOneAsync(future, query);
 1086  
 
 1087  4
         return future;
 1088  
     }
 1089  
 
 1090  
     /**
 1091  
      * {@inheritDoc}
 1092  
      * <p>
 1093  
      * Overridden to call the {@link #findOneAsync(Find)} method.
 1094  
      * </p>
 1095  
      */
 1096  
     @Override
 1097  
     public ListenableFuture<Document> findOneAsync(final Find.Builder query)
 1098  
             throws MongoDbException {
 1099  3
         return findOneAsync(query.build());
 1100  
     }
 1101  
 
 1102  
     /**
 1103  
      * {@inheritDoc}
 1104  
      * <p>
 1105  
      * Overridden to call the {@link #findAsync(Callback, DocumentAssignable)}
 1106  
      * method with an adapter for the {@link LambdaCallback}.
 1107  
      * </p>
 1108  
      */
 1109  
     @Override
 1110  
     public void findOneAsync(final LambdaCallback<Document> results,
 1111  
             final DocumentAssignable query) throws MongoDbException {
 1112  1
         findOneAsync(new LambdaCallbackAdapter<Document>(results), query);
 1113  1
     }
 1114  
 
 1115  
     /**
 1116  
      * {@inheritDoc}
 1117  
      * <p>
 1118  
      * Overridden to call the {@link #findAsync(Callback, Find)} method with an
 1119  
      * adapter for the {@link LambdaCallback}.
 1120  
      * </p>
 1121  
      */
 1122  
     @Override
 1123  
     public void findOneAsync(final LambdaCallback<Document> results,
 1124  
             final Find query) throws MongoDbException {
 1125  1
         findOneAsync(new LambdaCallbackAdapter<Document>(results), query);
 1126  1
     }
 1127  
 
 1128  
     /**
 1129  
      * {@inheritDoc}
 1130  
      * <p>
 1131  
      * Overridden to call the {@link #findAsync(Callback, Find.Builder)} method
 1132  
      * with an adapter for the {@link LambdaCallback}.
 1133  
      * </p>
 1134  
      */
 1135  
     @Override
 1136  
     public void findOneAsync(final LambdaCallback<Document> results,
 1137  
             final Find.Builder query) throws MongoDbException {
 1138  1
         findOneAsync(new LambdaCallbackAdapter<Document>(results), query);
 1139  1
     }
 1140  
 
 1141  
     /**
 1142  
      * {@inheritDoc}
 1143  
      * <p>
 1144  
      * Overridden to call the {@link #groupByAsync(Callback,GroupBy)}.
 1145  
      * </p>
 1146  
      */
 1147  
     @Override
 1148  
     public void groupByAsync(final Callback<MongoIterator<Element>> results,
 1149  
             final GroupBy.Builder command) throws MongoDbException {
 1150  2
         groupByAsync(results, command.build());
 1151  2
     }
 1152  
 
 1153  
     /**
 1154  
      * {@inheritDoc}
 1155  
      * <p>
 1156  
      * Overridden to call the {@link #groupByAsync(Callback, GroupBy)}.
 1157  
      * </p>
 1158  
      */
 1159  
     @Override
 1160  
     public ListenableFuture<MongoIterator<Element>> groupByAsync(
 1161  
             final GroupBy command) throws MongoDbException {
 1162  2
         final FutureCallback<MongoIterator<Element>> future = new FutureCallback<MongoIterator<Element>>(
 1163  
                 getLockType());
 1164  
 
 1165  2
         groupByAsync(future, command);
 1166  
 
 1167  2
         return future;
 1168  
     }
 1169  
 
 1170  
     /**
 1171  
      * {@inheritDoc}
 1172  
      * <p>
 1173  
      * Overridden to call the {@link #groupByAsync(GroupBy)}.
 1174  
      * </p>
 1175  
      */
 1176  
     @Override
 1177  
     public ListenableFuture<MongoIterator<Element>> groupByAsync(
 1178  
             final GroupBy.Builder command) throws MongoDbException {
 1179  1
         return groupByAsync(command.build());
 1180  
     }
 1181  
 
 1182  
     /**
 1183  
      * {@inheritDoc}
 1184  
      * <p>
 1185  
      * Overridden to call the {@link #groupByAsync(Callback, GroupBy)} method
 1186  
      * with an adapter for the {@link LambdaCallback}.
 1187  
      * </p>
 1188  
      */
 1189  
     @Override
 1190  
     public void groupByAsync(
 1191  
             final LambdaCallback<MongoIterator<Element>> results,
 1192  
             final GroupBy command) throws MongoDbException {
 1193  1
         groupByAsync(
 1194  
                 new LambdaCallbackAdapter<MongoIterator<Element>>(results),
 1195  
                 command);
 1196  1
     }
 1197  
 
 1198  
     /**
 1199  
      * {@inheritDoc}
 1200  
      * <p>
 1201  
      * Overridden to call the {@link #groupByAsync(Callback, GroupBy.Builder)}
 1202  
      * method with an adapter for the {@link LambdaCallback}.
 1203  
      * </p>
 1204  
      */
 1205  
     @Override
 1206  
     public void groupByAsync(
 1207  
             final LambdaCallback<MongoIterator<Element>> results,
 1208  
             final GroupBy.Builder command) throws MongoDbException {
 1209  1
         groupByAsync(
 1210  
                 new LambdaCallbackAdapter<MongoIterator<Element>>(results),
 1211  
                 command);
 1212  1
     }
 1213  
 
 1214  
     /**
 1215  
      * {@inheritDoc}
 1216  
      * <p>
 1217  
      * Overridden to call the
 1218  
      * {@link #insertAsync(Callback, boolean, Durability, DocumentAssignable...)}
 1219  
      * method with the {@link #getDurability() default durability}.
 1220  
      * </p>
 1221  
      * 
 1222  
      * @see MongoCollection#insertAsync(Callback, boolean, Durability,
 1223  
      *      DocumentAssignable[])
 1224  
      */
 1225  
     @Override
 1226  
     public ListenableFuture<Integer> insertAsync(final boolean continueOnError,
 1227  
             final DocumentAssignable... documents) throws MongoDbException {
 1228  1
         final FutureCallback<Integer> future = new FutureCallback<Integer>(
 1229  
                 getLockType());
 1230  
 
 1231  1
         insertAsync(future, continueOnError, getDurability(), documents);
 1232  
 
 1233  1
         return future;
 1234  
     }
 1235  
 
 1236  
     /**
 1237  
      * {@inheritDoc}
 1238  
      * <p>
 1239  
      * Overridden to call the
 1240  
      * {@link #insertAsync(Callback, boolean, Durability, DocumentAssignable...)}
 1241  
      * method with <tt>continueOnError</tt> set to false and the
 1242  
      * {@link #getDurability() default durability}.
 1243  
      * </p>
 1244  
      * 
 1245  
      * @see MongoCollection#insertAsync(Callback, boolean, Durability,
 1246  
      *      DocumentAssignable[])
 1247  
      */
 1248  
     @Override
 1249  
     public ListenableFuture<Integer> insertAsync(final boolean continueOnError,
 1250  
             final Durability durability, final DocumentAssignable... documents)
 1251  
             throws MongoDbException {
 1252  7
         final FutureCallback<Integer> future = new FutureCallback<Integer>(
 1253  
                 getLockType());
 1254  
 
 1255  7
         insertAsync(future, continueOnError, durability, documents);
 1256  
 
 1257  7
         return future;
 1258  
     }
 1259  
 
 1260  
     /**
 1261  
      * {@inheritDoc}
 1262  
      * <p>
 1263  
      * Overridden to call the
 1264  
      * {@link #insertAsync(Callback, boolean, Durability, DocumentAssignable...)}
 1265  
      * method the {@link #getDurability() default durability}.
 1266  
      * </p>
 1267  
      * 
 1268  
      * @see MongoCollection#insertAsync(Callback, boolean, Durability,
 1269  
      *      DocumentAssignable[])
 1270  
      */
 1271  
     @Override
 1272  
     public void insertAsync(final Callback<Integer> results,
 1273  
             final boolean continueOnError,
 1274  
             final DocumentAssignable... documents) throws MongoDbException {
 1275  2
         insertAsync(results, continueOnError, getDurability(), documents);
 1276  2
     }
 1277  
 
 1278  
     /**
 1279  
      * {@inheritDoc}
 1280  
      * <p>
 1281  
      * Overridden to call the
 1282  
      * {@link #insertAsync(Callback, boolean, Durability, DocumentAssignable...)}
 1283  
      * method with <tt>continueOnError</tt> set to false and the
 1284  
      * {@link #getDurability() default durability}.
 1285  
      * </p>
 1286  
      * 
 1287  
      * @see MongoCollection#insertAsync(Callback, boolean, Durability,
 1288  
      *      DocumentAssignable[])
 1289  
      */
 1290  
     @Override
 1291  
     public void insertAsync(final Callback<Integer> results,
 1292  
             final DocumentAssignable... documents) throws MongoDbException {
 1293  2
         insertAsync(results, INSERT_CONTINUE_ON_ERROR_DEFAULT, getDurability(),
 1294  
                 documents);
 1295  2
     }
 1296  
 
 1297  
     /**
 1298  
      * {@inheritDoc}
 1299  
      * <p>
 1300  
      * Overridden to call the
 1301  
      * {@link #insertAsync(Callback, boolean, Durability, DocumentAssignable...)}
 1302  
      * method with <tt>continueOnError</tt> set to false.
 1303  
      * </p>
 1304  
      * 
 1305  
      * @see MongoCollection#insertAsync(Callback, boolean, Durability,
 1306  
      *      DocumentAssignable[])
 1307  
      */
 1308  
     @Override
 1309  
     public void insertAsync(final Callback<Integer> results,
 1310  
             final Durability durability, final DocumentAssignable... documents)
 1311  
             throws MongoDbException {
 1312  2
         insertAsync(results, INSERT_CONTINUE_ON_ERROR_DEFAULT, durability,
 1313  
                 documents);
 1314  2
     }
 1315  
 
 1316  
     /**
 1317  
      * {@inheritDoc}
 1318  
      * <p>
 1319  
      * Overridden to call the
 1320  
      * {@link #insertAsync(Callback, boolean, Durability, DocumentAssignable...)}
 1321  
      * method with <tt>continueOnError</tt> set to false and the
 1322  
      * {@link #getDurability() default durability}.
 1323  
      * </p>
 1324  
      * 
 1325  
      * @see MongoCollection#insertAsync(Callback, boolean, Durability,
 1326  
      *      DocumentAssignable[])
 1327  
      */
 1328  
     @Override
 1329  
     public ListenableFuture<Integer> insertAsync(
 1330  
             final DocumentAssignable... documents) throws MongoDbException {
 1331  12
         final FutureCallback<Integer> future = new FutureCallback<Integer>(
 1332  
                 getLockType());
 1333  
 
 1334  12
         insertAsync(future, INSERT_CONTINUE_ON_ERROR_DEFAULT, getDurability(),
 1335  
                 documents);
 1336  
 
 1337  12
         return future;
 1338  
     }
 1339  
 
 1340  
     /**
 1341  
      * {@inheritDoc}
 1342  
      * <p>
 1343  
      * Overridden to call the
 1344  
      * {@link #insertAsync(Callback, boolean, Durability, DocumentAssignable...)}
 1345  
      * method with <tt>continueOnError</tt> set to false.
 1346  
      * </p>
 1347  
      * 
 1348  
      * @see MongoCollection#insertAsync(Callback, boolean, Durability,
 1349  
      *      DocumentAssignable[])
 1350  
      */
 1351  
     @Override
 1352  
     public ListenableFuture<Integer> insertAsync(final Durability durability,
 1353  
             final DocumentAssignable... documents) throws MongoDbException {
 1354  1
         final FutureCallback<Integer> future = new FutureCallback<Integer>(
 1355  
                 getLockType());
 1356  
 
 1357  1
         insertAsync(future, INSERT_CONTINUE_ON_ERROR_DEFAULT, durability,
 1358  
                 documents);
 1359  
 
 1360  1
         return future;
 1361  
     }
 1362  
 
 1363  
     /**
 1364  
      * {@inheritDoc}
 1365  
      * <p>
 1366  
      * Overridden to call the
 1367  
      * {@link #insertAsync(Callback, boolean, DocumentAssignable[])} method with
 1368  
      * an adapter for the {@link LambdaCallback}.
 1369  
      * </p>
 1370  
      */
 1371  
     @Override
 1372  
     public void insertAsync(final LambdaCallback<Integer> results,
 1373  
             final boolean continueOnError,
 1374  
             final DocumentAssignable... documents) throws MongoDbException {
 1375  1
         insertAsync(new LambdaCallbackAdapter<Integer>(results),
 1376  
                 continueOnError, documents);
 1377  1
     }
 1378  
 
 1379  
     /**
 1380  
      * {@inheritDoc}
 1381  
      * <p>
 1382  
      * Overridden to call the
 1383  
      * {@link #insertAsync(Callback, boolean, Durability, DocumentAssignable[])}
 1384  
      * method with an adapter for the {@link LambdaCallback}.
 1385  
      * </p>
 1386  
      */
 1387  
     @Override
 1388  
     public void insertAsync(final LambdaCallback<Integer> results,
 1389  
             final boolean continueOnError, final Durability durability,
 1390  
             final DocumentAssignable... documents) throws MongoDbException {
 1391  1
         insertAsync(new LambdaCallbackAdapter<Integer>(results),
 1392  
                 continueOnError, durability, documents);
 1393  1
     }
 1394  
 
 1395  
     /**
 1396  
      * {@inheritDoc}
 1397  
      * <p>
 1398  
      * Overridden to call the
 1399  
      * {@link #insertAsync(Callback, DocumentAssignable[])} method with an
 1400  
      * adapter for the {@link LambdaCallback}.
 1401  
      * </p>
 1402  
      */
 1403  
     @Override
 1404  
     public void insertAsync(final LambdaCallback<Integer> results,
 1405  
             final DocumentAssignable... documents) throws MongoDbException {
 1406  1
         insertAsync(new LambdaCallbackAdapter<Integer>(results), documents);
 1407  1
     }
 1408  
 
 1409  
     /**
 1410  
      * {@inheritDoc}
 1411  
      * <p>
 1412  
      * Overridden to call the
 1413  
      * {@link #insertAsync(Callback, Durability, DocumentAssignable[])} method
 1414  
      * with an adapter for the {@link LambdaCallback}.
 1415  
      * </p>
 1416  
      */
 1417  
     @Override
 1418  
     public void insertAsync(final LambdaCallback<Integer> results,
 1419  
             final Durability durability, final DocumentAssignable... documents)
 1420  
             throws MongoDbException {
 1421  1
         insertAsync(new LambdaCallbackAdapter<Integer>(results), durability,
 1422  
                 documents);
 1423  1
     }
 1424  
 
 1425  
     /**
 1426  
      * {@inheritDoc}
 1427  
      * <p>
 1428  
      * Overridden to call the {@link #mapReduceAsync(Callback,MapReduce)}.
 1429  
      * </p>
 1430  
      */
 1431  
     @Override
 1432  
     public void mapReduceAsync(final Callback<MongoIterator<Document>> results,
 1433  
             final MapReduce.Builder command) throws MongoDbException {
 1434  2
         mapReduceAsync(results, command.build());
 1435  2
     }
 1436  
 
 1437  
     /**
 1438  
      * {@inheritDoc}
 1439  
      * <p>
 1440  
      * Overridden to call the {@link #mapReduceAsync(Callback, MapReduce)}
 1441  
      * method with an adapter for the {@link LambdaCallback}.
 1442  
      * </p>
 1443  
      */
 1444  
     @Override
 1445  
     public void mapReduceAsync(
 1446  
             final LambdaCallback<MongoIterator<Document>> results,
 1447  
             final MapReduce command) throws MongoDbException {
 1448  1
         mapReduceAsync(new LambdaCallbackAdapter<MongoIterator<Document>>(
 1449  
                 results), command);
 1450  1
     }
 1451  
 
 1452  
     /**
 1453  
      * {@inheritDoc}
 1454  
      * <p>
 1455  
      * Overridden to call the
 1456  
      * {@link #mapReduceAsync(Callback, MapReduce.Builder)} method with an
 1457  
      * adapter for the {@link LambdaCallback}.
 1458  
      * </p>
 1459  
      */
 1460  
     @Override
 1461  
     public void mapReduceAsync(
 1462  
             final LambdaCallback<MongoIterator<Document>> results,
 1463  
             final MapReduce.Builder command) throws MongoDbException {
 1464  1
         mapReduceAsync(new LambdaCallbackAdapter<MongoIterator<Document>>(
 1465  
                 results), command);
 1466  1
     }
 1467  
 
 1468  
     /**
 1469  
      * {@inheritDoc}
 1470  
      * <p>
 1471  
      * Overridden to call the {@link #mapReduceAsync(Callback, MapReduce)}.
 1472  
      * </p>
 1473  
      * 
 1474  
      * @see #mapReduceAsync(Callback, MapReduce)
 1475  
      */
 1476  
     @Override
 1477  
     public ListenableFuture<MongoIterator<Document>> mapReduceAsync(
 1478  
             final MapReduce command) throws MongoDbException {
 1479  2
         final FutureCallback<MongoIterator<Document>> future = new FutureCallback<MongoIterator<Document>>(
 1480  
                 getLockType());
 1481  
 
 1482  2
         mapReduceAsync(future, command);
 1483  
 
 1484  2
         return future;
 1485  
     }
 1486  
 
 1487  
     /**
 1488  
      * {@inheritDoc}
 1489  
      * <p>
 1490  
      * Overridden to call the {@link #mapReduceAsync(MapReduce)}.
 1491  
      * </p>
 1492  
      */
 1493  
     @Override
 1494  
     public ListenableFuture<MongoIterator<Document>> mapReduceAsync(
 1495  
             final MapReduce.Builder command) throws MongoDbException {
 1496  1
         return mapReduceAsync(command.build());
 1497  
     }
 1498  
 
 1499  
     /**
 1500  
      * {@inheritDoc}
 1501  
      * <p>
 1502  
      * Overridden to call the {@link #parallelScanAsync(Callback, ParallelScan)}
 1503  
      * .
 1504  
      * </p>
 1505  
      */
 1506  
     @Override
 1507  
     public void parallelScanAsync(
 1508  
             final Callback<Collection<MongoIterator<Document>>> results,
 1509  
             final ParallelScan.Builder parallelScan) throws MongoDbException {
 1510  1
         parallelScanAsync(results, parallelScan.build());
 1511  1
     }
 1512  
 
 1513  
     /**
 1514  
      * {@inheritDoc}
 1515  
      * <p>
 1516  
      * Overridden to call the {@link #parallelScanAsync(Callback, ParallelScan)}
 1517  
      * method with an adapter for the {@link LambdaCallback}.
 1518  
      * </p>
 1519  
      */
 1520  
     @Override
 1521  
     public void parallelScanAsync(
 1522  
             final LambdaCallback<Collection<MongoIterator<Document>>> results,
 1523  
             final ParallelScan parallelScan) throws MongoDbException {
 1524  0
         parallelScanAsync(
 1525  
                 new LambdaCallbackAdapter<Collection<MongoIterator<Document>>>(
 1526  
                         results), parallelScan);
 1527  
 
 1528  0
     }
 1529  
 
 1530  
     /**
 1531  
      * {@inheritDoc}
 1532  
      * <p>
 1533  
      * Overridden to call the
 1534  
      * {@link #parallelScanAsync(LambdaCallback, ParallelScan)} method.
 1535  
      * </p>
 1536  
      */
 1537  
     @Override
 1538  
     public void parallelScanAsync(
 1539  
             final LambdaCallback<Collection<MongoIterator<Document>>> results,
 1540  
             final ParallelScan.Builder parallelScan) throws MongoDbException {
 1541  0
         parallelScanAsync(results, parallelScan.build());
 1542  
 
 1543  0
     }
 1544  
 
 1545  
     /**
 1546  
      * {@inheritDoc}
 1547  
      * <p>
 1548  
      * Overridden to call the {@link #parallelScanAsync(Callback, ParallelScan)}
 1549  
      * .
 1550  
      * </p>
 1551  
      */
 1552  
     @Override
 1553  
     public ListenableFuture<Collection<MongoIterator<Document>>> parallelScanAsync(
 1554  
             final ParallelScan parallelScan) throws MongoDbException {
 1555  
         final FutureCallback<Collection<MongoIterator<Document>>> future;
 1556  2
         future = new FutureCallback<Collection<MongoIterator<Document>>>(
 1557  
                 getLockType());
 1558  
 
 1559  2
         parallelScanAsync(future, parallelScan);
 1560  
 
 1561  2
         return future;
 1562  
     }
 1563  
 
 1564  
     /**
 1565  
      * {@inheritDoc}
 1566  
      * <p>
 1567  
      * Overridden to call the {@link #parallelScanAsync(Callback, ParallelScan)}
 1568  
      * .
 1569  
      * </p>
 1570  
      */
 1571  
     @Override
 1572  
     public ListenableFuture<Collection<MongoIterator<Document>>> parallelScanAsync(
 1573  
             final ParallelScan.Builder parallelScan) throws MongoDbException {
 1574  1
         return parallelScanAsync(parallelScan.build());
 1575  
     }
 1576  
 
 1577  
     /**
 1578  
      * {@inheritDoc}
 1579  
      * <p>
 1580  
      * Overridden to call the
 1581  
      * {@link #saveAsync(Callback, DocumentAssignable, Durability)} using the
 1582  
      * {@link #getDurability() default durability}.
 1583  
      * </p>
 1584  
      */
 1585  
     @Override
 1586  
     public void saveAsync(final Callback<Integer> results,
 1587  
             final DocumentAssignable document) throws MongoDbException {
 1588  2
         saveAsync(results, document, getDurability());
 1589  2
     }
 1590  
 
 1591  
     /**
 1592  
      * {@inheritDoc}
 1593  
      * <p>
 1594  
      * Overridden to call the
 1595  
      * {@link #saveAsync(Callback, DocumentAssignable, Durability)} using the
 1596  
      * {@link #getDurability() default durability}.
 1597  
      * </p>
 1598  
      */
 1599  
     @Override
 1600  
     public ListenableFuture<Integer> saveAsync(final DocumentAssignable document)
 1601  
             throws MongoDbException {
 1602  1
         final FutureCallback<Integer> future = new FutureCallback<Integer>(
 1603  
                 getLockType());
 1604  
 
 1605  1
         saveAsync(future, document, getDurability());
 1606  
 
 1607  1
         return future;
 1608  
     }
 1609  
 
 1610  
     /**
 1611  
      * {@inheritDoc}
 1612  
      * <p>
 1613  
      * Overridden to call the
 1614  
      * {@link #saveAsync(Callback, DocumentAssignable, Durability)}.
 1615  
      * </p>
 1616  
      */
 1617  
     @Override
 1618  
     public ListenableFuture<Integer> saveAsync(
 1619  
             final DocumentAssignable document, final Durability durability)
 1620  
             throws MongoDbException {
 1621  3
         final FutureCallback<Integer> future = new FutureCallback<Integer>(
 1622  
                 getLockType());
 1623  
 
 1624  3
         saveAsync(future, document, durability);
 1625  
 
 1626  3
         return future;
 1627  
     }
 1628  
 
 1629  
     /**
 1630  
      * {@inheritDoc}
 1631  
      * <p>
 1632  
      * Overridden to call the {@link #saveAsync(Callback, DocumentAssignable)}
 1633  
      * method with an adapter for the {@link LambdaCallback}.
 1634  
      * </p>
 1635  
      */
 1636  
     @Override
 1637  
     public void saveAsync(final LambdaCallback<Integer> results,
 1638  
             final DocumentAssignable document) throws MongoDbException {
 1639  1
         saveAsync(new LambdaCallbackAdapter<Integer>(results), document);
 1640  1
     }
 1641  
 
 1642  
     /**
 1643  
      * {@inheritDoc}
 1644  
      * <p>
 1645  
      * Overridden to call the
 1646  
      * {@link #saveAsync(Callback, DocumentAssignable, Durability)} method with
 1647  
      * an adapter for the {@link LambdaCallback}.
 1648  
      * </p>
 1649  
      */
 1650  
     @Override
 1651  
     public void saveAsync(final LambdaCallback<Integer> results,
 1652  
             final DocumentAssignable document, final Durability durability)
 1653  
             throws MongoDbException {
 1654  1
         saveAsync(new LambdaCallbackAdapter<Integer>(results), document,
 1655  
                 durability);
 1656  1
     }
 1657  
 
 1658  
     /**
 1659  
      * {@inheritDoc}
 1660  
      * <p>
 1661  
      * Overridden to call the {@link #stream(StreamCallback, Aggregate)} method
 1662  
      * with an adapter for the {@link LambdaCallback}.
 1663  
      * </p>
 1664  
      */
 1665  
     @Override
 1666  
     public MongoCursorControl stream(final LambdaCallback<Document> results,
 1667  
             final Aggregate aggregation) throws MongoDbException {
 1668  1
         return stream(new LambdaCallbackAdapter<Document>(results), aggregation);
 1669  
     }
 1670  
 
 1671  
     /**
 1672  
      * {@inheritDoc}
 1673  
      * <p>
 1674  
      * Overridden to call the {@link #stream(StreamCallback, Aggregate.Builder)}
 1675  
      * method with an adapter for the {@link LambdaCallback}.
 1676  
      * </p>
 1677  
      */
 1678  
     @Override
 1679  
     public MongoCursorControl stream(final LambdaCallback<Document> results,
 1680  
             final Aggregate.Builder aggregation) throws MongoDbException {
 1681  1
         return stream(new LambdaCallbackAdapter<Document>(results), aggregation);
 1682  
     }
 1683  
 
 1684  
     /**
 1685  
      * {@inheritDoc}
 1686  
      * <p>
 1687  
      * Overridden to call the {@link #stream(StreamCallback, Find)} method with
 1688  
      * an adapter for the {@link LambdaCallback}.
 1689  
      * </p>
 1690  
      */
 1691  
     @Override
 1692  
     public MongoCursorControl stream(final LambdaCallback<Document> results,
 1693  
             final Find query) throws MongoDbException {
 1694  1
         return stream(new LambdaCallbackAdapter<Document>(results), query);
 1695  
     }
 1696  
 
 1697  
     /**
 1698  
      * {@inheritDoc}
 1699  
      * <p>
 1700  
      * Overridden to call the {@link #stream(StreamCallback, Find.Builder)}
 1701  
      * method with an adapter for the {@link LambdaCallback}.
 1702  
      * </p>
 1703  
      */
 1704  
     @Override
 1705  
     public MongoCursorControl stream(final LambdaCallback<Document> results,
 1706  
             final Find.Builder aggregation) throws MongoDbException {
 1707  1
         return stream(new LambdaCallbackAdapter<Document>(results), aggregation);
 1708  
     }
 1709  
 
 1710  
     /**
 1711  
      * {@inheritDoc}
 1712  
      * <p>
 1713  
      * Overridden to call the {@link #stream(StreamCallback, Aggregate)}.
 1714  
      * </p>
 1715  
      * 
 1716  
      * @see #stream(StreamCallback, Aggregate)
 1717  
      */
 1718  
     @Override
 1719  
     public MongoCursorControl stream(final StreamCallback<Document> results,
 1720  
             final Aggregate.Builder aggregation) throws MongoDbException {
 1721  2
         return stream(results, aggregation.build());
 1722  
     }
 1723  
 
 1724  
     /**
 1725  
      * {@inheritDoc}
 1726  
      * <p>
 1727  
      * Overridden to call the {@link #stream(StreamCallback, Find)} method.
 1728  
      * </p>
 1729  
      */
 1730  
     @Override
 1731  
     public MongoCursorControl stream(final StreamCallback<Document> results,
 1732  
             final Find.Builder query) throws MongoDbException {
 1733  2
         return streamingFind(results, query.build());
 1734  
     }
 1735  
 
 1736  
     /**
 1737  
      * {@inheritDoc}
 1738  
      * <p>
 1739  
      * Overridden to call the {@link #streamingFind(Callback, Find)}.
 1740  
      * </p>
 1741  
      * 
 1742  
      * @see #streamingFind(Callback, Find)
 1743  
      */
 1744  
     @Deprecated
 1745  
     @Override
 1746  
     public MongoCursorControl streamingFind(final Callback<Document> results,
 1747  
             final DocumentAssignable query) throws MongoDbException {
 1748  1
         return streamingFind(results, new Find.Builder(query).build());
 1749  
     }
 1750  
 
 1751  
     /**
 1752  
      * {@inheritDoc}
 1753  
      * <p>
 1754  
      * Overridden to call the {@link #stream(StreamCallback, Find)}.
 1755  
      * </p>
 1756  
      * 
 1757  
      * @see #stream(StreamCallback, Find)
 1758  
      */
 1759  
     @Deprecated
 1760  
     @Override
 1761  
     public MongoCursorControl streamingFind(final Callback<Document> results,
 1762  
             final Find query) throws MongoDbException {
 1763  4
         return stream(
 1764  
                 new com.allanbank.mongodb.client.callback.LegacyStreamCallbackAdapter(
 1765  
                         results), query);
 1766  
     }
 1767  
 
 1768  
     /**
 1769  
      * {@inheritDoc}
 1770  
      * <p>
 1771  
      * Overridden to call the
 1772  
      * {@link #streamingFind(StreamCallback, DocumentAssignable)} method with an
 1773  
      * adapter for the {@link LambdaCallback}.
 1774  
      * </p>
 1775  
      */
 1776  
     @Override
 1777  
     public MongoCursorControl streamingFind(
 1778  
             final LambdaCallback<Document> results,
 1779  
             final DocumentAssignable query) throws MongoDbException {
 1780  1
         return streamingFind(new LambdaCallbackAdapter<Document>(results),
 1781  
                 query);
 1782  
     }
 1783  
 
 1784  
     /**
 1785  
      * {@inheritDoc}
 1786  
      * <p>
 1787  
      * Overridden to call the {@link #stream(StreamCallback, Find)}.
 1788  
      * </p>
 1789  
      * 
 1790  
      * @see #stream(StreamCallback, Find)
 1791  
      */
 1792  
     @Override
 1793  
     public MongoCursorControl streamingFind(
 1794  
             final StreamCallback<Document> results,
 1795  
             final DocumentAssignable query) throws MongoDbException {
 1796  2
         return stream(results, new Find.Builder(query).build());
 1797  
     }
 1798  
 
 1799  
     /**
 1800  
      * {@inheritDoc}
 1801  
      * <p>
 1802  
      * Overridden to call the {@link #streamingFind(StreamCallback, Find)}.
 1803  
      * </p>
 1804  
      * 
 1805  
      * @see #stream(StreamCallback, Find)
 1806  
      */
 1807  
     @Deprecated
 1808  
     @Override
 1809  
     public MongoCursorControl streamingFind(
 1810  
             final StreamCallback<Document> results, final Find query)
 1811  
             throws MongoDbException {
 1812  2
         return stream(results, query);
 1813  
     }
 1814  
 
 1815  
     /**
 1816  
      * {@inheritDoc}
 1817  
      * <p>
 1818  
      * Overridden to call the {@link #streamingFind(StreamCallback, Find)}
 1819  
      * method.
 1820  
      * </p>
 1821  
      */
 1822  
     @Deprecated
 1823  
     @Override
 1824  
     public MongoCursorControl streamingFind(
 1825  
             final StreamCallback<Document> results, final Find.Builder query)
 1826  
             throws MongoDbException {
 1827  0
         return streamingFind(results, query.build());
 1828  
     }
 1829  
 
 1830  
     /**
 1831  
      * {@inheritDoc}
 1832  
      * <p>
 1833  
      * Overridden to call the
 1834  
      * {@link #textSearchAsync(Callback, com.allanbank.mongodb.builder.Text)}.
 1835  
      * </p>
 1836  
      * 
 1837  
      * @deprecated Support for the {@code text} command was deprecated in the
 1838  
      *             2.6 version of MongoDB. Use the
 1839  
      *             {@link ConditionBuilder#text(String) $text} query operator
 1840  
      *             instead. This method will not be removed until two releases
 1841  
      *             after the MongoDB 2.6 release (e.g. 2.10 if the releases are
 1842  
      *             2.8 and 2.10).
 1843  
      */
 1844  
     @Deprecated
 1845  
     @Override
 1846  
     public void textSearchAsync(
 1847  
             final Callback<MongoIterator<com.allanbank.mongodb.builder.TextResult>> results,
 1848  
             final com.allanbank.mongodb.builder.Text.Builder command)
 1849  
             throws MongoDbException {
 1850  0
         textSearchAsync(results, command.build());
 1851  0
     }
 1852  
 
 1853  
     /**
 1854  
      * {@inheritDoc}
 1855  
      * <p>
 1856  
      * Overridden to call the
 1857  
      * {@link #textSearchAsync(Callback, com.allanbank.mongodb.builder.Text)}.
 1858  
      * </p>
 1859  
      * 
 1860  
      * @see #textSearchAsync(Callback, com.allanbank.mongodb.builder.Text)
 1861  
      * @deprecated Support for the {@code text} command was deprecated in the
 1862  
      *             2.6 version of MongoDB. Use the
 1863  
      *             {@link ConditionBuilder#text(String) $text} query operator
 1864  
      *             instead. This method will not be removed until two releases
 1865  
      *             after the MongoDB 2.6 release (e.g. 2.10 if the releases are
 1866  
      *             2.8 and 2.10).
 1867  
      */
 1868  
     @Deprecated
 1869  
     @Override
 1870  
     public ListenableFuture<MongoIterator<com.allanbank.mongodb.builder.TextResult>> textSearchAsync(
 1871  
             final com.allanbank.mongodb.builder.Text command)
 1872  
             throws MongoDbException {
 1873  
         final FutureCallback<MongoIterator<com.allanbank.mongodb.builder.TextResult>> future;
 1874  2
         future = new FutureCallback<MongoIterator<com.allanbank.mongodb.builder.TextResult>>(
 1875  
                 getLockType());
 1876  
 
 1877  2
         textSearchAsync(future, command);
 1878  
 
 1879  2
         return future;
 1880  
     }
 1881  
 
 1882  
     /**
 1883  
      * {@inheritDoc}
 1884  
      * <p>
 1885  
      * Overridden to call the
 1886  
      * {@link #textSearchAsync(com.allanbank.mongodb.builder.Text)}.
 1887  
      * </p>
 1888  
      * 
 1889  
      * @deprecated Support for the {@code text} command was deprecated in the
 1890  
      *             2.6 version of MongoDB. Use the
 1891  
      *             {@link ConditionBuilder#text(String) $text} query operator
 1892  
      *             instead. This method will not be removed until two releases
 1893  
      *             after the MongoDB 2.6 release (e.g. 2.10 if the releases are
 1894  
      *             2.8 and 2.10).
 1895  
      */
 1896  
     @Deprecated
 1897  
     @Override
 1898  
     public ListenableFuture<MongoIterator<com.allanbank.mongodb.builder.TextResult>> textSearchAsync(
 1899  
             final com.allanbank.mongodb.builder.Text.Builder command)
 1900  
             throws MongoDbException {
 1901  0
         return textSearchAsync(command.build());
 1902  
     }
 1903  
 
 1904  
     /**
 1905  
      * {@inheritDoc}
 1906  
      * <p>
 1907  
      * Overridden to call the
 1908  
      * {@link #updateAsync(Callback, DocumentAssignable, DocumentAssignable, boolean, boolean, Durability)}
 1909  
      * with multiUpdate set to true, upsert set to false, and using the
 1910  
      * {@link #getDurability() default durability}.
 1911  
      * </p>
 1912  
      * 
 1913  
      * @see #updateAsync(Callback, DocumentAssignable, DocumentAssignable,
 1914  
      *      boolean, boolean, Durability)
 1915  
      */
 1916  
     @Override
 1917  
     public void updateAsync(final Callback<Long> results,
 1918  
             final DocumentAssignable query, final DocumentAssignable update)
 1919  
             throws MongoDbException {
 1920  2
         updateAsync(results, query, update, UPDATE_MULTIUPDATE_DEFAULT,
 1921  
                 UPDATE_UPSERT_DEFAULT, getDurability());
 1922  2
     }
 1923  
 
 1924  
     /**
 1925  
      * {@inheritDoc}
 1926  
      * <p>
 1927  
      * Overridden to call the
 1928  
      * {@link #updateAsync(Callback, DocumentAssignable, DocumentAssignable, boolean, boolean, Durability)}
 1929  
      * using the {@link #getDurability() default durability}.
 1930  
      * </p>
 1931  
      * 
 1932  
      * @see #updateAsync(Callback, DocumentAssignable, DocumentAssignable,
 1933  
      *      boolean, boolean, Durability)
 1934  
      */
 1935  
     @Override
 1936  
     public void updateAsync(final Callback<Long> results,
 1937  
             final DocumentAssignable query, final DocumentAssignable update,
 1938  
             final boolean multiUpdate, final boolean upsert)
 1939  
             throws MongoDbException {
 1940  2
         updateAsync(results, query, update, multiUpdate, upsert,
 1941  
                 getDurability());
 1942  2
     }
 1943  
 
 1944  
     /**
 1945  
      * {@inheritDoc}
 1946  
      * <p>
 1947  
      * Overridden to call the
 1948  
      * {@link #updateAsync(Callback, DocumentAssignable, DocumentAssignable, boolean, boolean, Durability)}
 1949  
      * with multiUpdate set to true, and upsert set to false.
 1950  
      * </p>
 1951  
      * 
 1952  
      * @see #updateAsync(Callback, DocumentAssignable, DocumentAssignable,
 1953  
      *      boolean, boolean, Durability)
 1954  
      */
 1955  
     @Override
 1956  
     public void updateAsync(final Callback<Long> results,
 1957  
             final DocumentAssignable query, final DocumentAssignable update,
 1958  
             final Durability durability) throws MongoDbException {
 1959  2
         updateAsync(results, query, update, UPDATE_MULTIUPDATE_DEFAULT,
 1960  
                 UPDATE_UPSERT_DEFAULT, durability);
 1961  2
     }
 1962  
 
 1963  
     /**
 1964  
      * {@inheritDoc}
 1965  
      * <p>
 1966  
      * Overridden to call the
 1967  
      * {@link #updateAsync(Callback, DocumentAssignable, DocumentAssignable, boolean, boolean, Durability)}
 1968  
      * with multiUpdate set to true, upsert set to false, and using the
 1969  
      * {@link #getDurability() default durability}.
 1970  
      * </p>
 1971  
      * 
 1972  
      * @see #updateAsync(Callback, DocumentAssignable, DocumentAssignable,
 1973  
      *      boolean, boolean, Durability)
 1974  
      */
 1975  
     @Override
 1976  
     public ListenableFuture<Long> updateAsync(final DocumentAssignable query,
 1977  
             final DocumentAssignable update) throws MongoDbException {
 1978  6
         final FutureCallback<Long> future = new FutureCallback<Long>(
 1979  
                 getLockType());
 1980  
 
 1981  6
         updateAsync(future, query, update, UPDATE_MULTIUPDATE_DEFAULT,
 1982  
                 UPDATE_UPSERT_DEFAULT, getDurability());
 1983  
 
 1984  6
         return future;
 1985  
     }
 1986  
 
 1987  
     /**
 1988  
      * {@inheritDoc}
 1989  
      * <p>
 1990  
      * Overridden to call the
 1991  
      * {@link #updateAsync(Callback, DocumentAssignable, DocumentAssignable, boolean, boolean, Durability)}
 1992  
      * using the {@link #getDurability() default durability}.
 1993  
      * </p>
 1994  
      * 
 1995  
      * @see #updateAsync(Callback, DocumentAssignable, DocumentAssignable,
 1996  
      *      boolean, boolean, Durability)
 1997  
      */
 1998  
     @Override
 1999  
     public ListenableFuture<Long> updateAsync(final DocumentAssignable query,
 2000  
             final DocumentAssignable update, final boolean multiUpdate,
 2001  
             final boolean upsert) throws MongoDbException {
 2002  2
         final FutureCallback<Long> future = new FutureCallback<Long>(
 2003  
                 getLockType());
 2004  
 
 2005  2
         updateAsync(future, query, update, multiUpdate, upsert, getDurability());
 2006  
 
 2007  2
         return future;
 2008  
     }
 2009  
 
 2010  
     /**
 2011  
      * {@inheritDoc}
 2012  
      * <p>
 2013  
      * Overridden to call the
 2014  
      * {@link #updateAsync(Callback, DocumentAssignable, DocumentAssignable, boolean, boolean, Durability)}
 2015  
      * method.
 2016  
      * </p>
 2017  
      * 
 2018  
      * @see #updateAsync(Callback, DocumentAssignable, DocumentAssignable,
 2019  
      *      boolean, boolean, Durability)
 2020  
      */
 2021  
     @Override
 2022  
     public ListenableFuture<Long> updateAsync(final DocumentAssignable query,
 2023  
             final DocumentAssignable update, final boolean multiUpdate,
 2024  
             final boolean upsert, final Durability durability)
 2025  
             throws MongoDbException {
 2026  5
         final FutureCallback<Long> future = new FutureCallback<Long>(
 2027  
                 getLockType());
 2028  
 
 2029  5
         updateAsync(future, query, update, multiUpdate, upsert, durability);
 2030  
 
 2031  5
         return future;
 2032  
     }
 2033  
 
 2034  
     /**
 2035  
      * {@inheritDoc}
 2036  
      * <p>
 2037  
      * Overridden to call the
 2038  
      * {@link #updateAsync(Callback, DocumentAssignable, DocumentAssignable, boolean, boolean, Durability)}
 2039  
      * with multiUpdate set to true, and upsert set to false.
 2040  
      * </p>
 2041  
      * 
 2042  
      * @see #updateAsync(Callback, DocumentAssignable, DocumentAssignable,
 2043  
      *      boolean, boolean, Durability)
 2044  
      */
 2045  
     @Override
 2046  
     public ListenableFuture<Long> updateAsync(final DocumentAssignable query,
 2047  
             final DocumentAssignable update, final Durability durability)
 2048  
             throws MongoDbException {
 2049  7
         final FutureCallback<Long> future = new FutureCallback<Long>(
 2050  
                 getLockType());
 2051  
 
 2052  7
         updateAsync(future, query, update, UPDATE_MULTIUPDATE_DEFAULT,
 2053  
                 UPDATE_UPSERT_DEFAULT, durability);
 2054  
 
 2055  7
         return future;
 2056  
     }
 2057  
 
 2058  
     /**
 2059  
      * {@inheritDoc}
 2060  
      * <p>
 2061  
      * Overridden to call the
 2062  
      * {@link #updateAsync(Callback, DocumentAssignable, DocumentAssignable)}
 2063  
      * method with an adapter for the {@link LambdaCallback}.
 2064  
      * </p>
 2065  
      */
 2066  
     @Override
 2067  
     public void updateAsync(final LambdaCallback<Long> results,
 2068  
             final DocumentAssignable query, final DocumentAssignable update)
 2069  
             throws MongoDbException {
 2070  1
         updateAsync(new LambdaCallbackAdapter<Long>(results), query, update);
 2071  1
     }
 2072  
 
 2073  
     /**
 2074  
      * {@inheritDoc}
 2075  
      * <p>
 2076  
      * Overridden to call the
 2077  
      * {@link #updateAsync(Callback, DocumentAssignable, DocumentAssignable, boolean, boolean)}
 2078  
      * method with an adapter for the {@link LambdaCallback}.
 2079  
      * </p>
 2080  
      */
 2081  
     @Override
 2082  
     public void updateAsync(final LambdaCallback<Long> results,
 2083  
             final DocumentAssignable query, final DocumentAssignable update,
 2084  
             final boolean multiUpdate, final boolean upsert)
 2085  
             throws MongoDbException {
 2086  1
         updateAsync(new LambdaCallbackAdapter<Long>(results), query, update,
 2087  
                 multiUpdate, upsert);
 2088  1
     }
 2089  
 
 2090  
     /**
 2091  
      * {@inheritDoc}
 2092  
      * <p>
 2093  
      * Overridden to call the
 2094  
      * {@link #updateAsync(Callback, DocumentAssignable, DocumentAssignable, boolean, boolean, Durability)}
 2095  
      * method with an adapter for the {@link LambdaCallback}.
 2096  
      * </p>
 2097  
      */
 2098  
     @Override
 2099  
     public void updateAsync(final LambdaCallback<Long> results,
 2100  
             final DocumentAssignable query, final DocumentAssignable update,
 2101  
             final boolean multiUpdate, final boolean upsert,
 2102  
             final Durability durability) throws MongoDbException {
 2103  1
         updateAsync(new LambdaCallbackAdapter<Long>(results), query, update,
 2104  
                 multiUpdate, upsert, durability);
 2105  1
     }
 2106  
 
 2107  
     /**
 2108  
      * {@inheritDoc}
 2109  
      * <p>
 2110  
      * Overridden to call the
 2111  
      * {@link #updateAsync(Callback, DocumentAssignable, DocumentAssignable, Durability)}
 2112  
      * method with an adapter for the {@link LambdaCallback}.
 2113  
      * </p>
 2114  
      */
 2115  
     @Override
 2116  
     public void updateAsync(final LambdaCallback<Long> results,
 2117  
             final DocumentAssignable query, final DocumentAssignable update,
 2118  
             final Durability durability) throws MongoDbException {
 2119  1
         updateAsync(new LambdaCallbackAdapter<Long>(results), query, update,
 2120  
                 durability);
 2121  1
     }
 2122  
 
 2123  
     /**
 2124  
      * {@inheritDoc}
 2125  
      * <p>
 2126  
      * Overridden to call the {@link #writeAsync(Callback, BatchedWrite)}
 2127  
      * method.
 2128  
      * </p>
 2129  
      * 
 2130  
      * @see #writeAsync(Callback, BatchedWrite)
 2131  
      */
 2132  
     @Override
 2133  
     public ListenableFuture<Long> writeAsync(final BatchedWrite write)
 2134  
             throws MongoDbException {
 2135  2
         final FutureCallback<Long> future = new FutureCallback<Long>(
 2136  
                 getLockType());
 2137  
 
 2138  2
         writeAsync(future, write);
 2139  
 
 2140  2
         return future;
 2141  
     }
 2142  
 
 2143  
     /**
 2144  
      * {@inheritDoc}
 2145  
      * <p>
 2146  
      * Overridden to call the {@link #writeAsync(BatchedWrite)} method.
 2147  
      * </p>
 2148  
      * 
 2149  
      * @see #writeAsync(BatchedWrite)
 2150  
      */
 2151  
     @Override
 2152  
     public ListenableFuture<Long> writeAsync(final BatchedWrite.Builder write)
 2153  
             throws MongoDbException {
 2154  1
         return writeAsync(write.build());
 2155  
     }
 2156  
 
 2157  
     /**
 2158  
      * {@inheritDoc}
 2159  
      * <p>
 2160  
      * Overridden to call the {@link #writeAsync(Callback, BatchedWrite)}
 2161  
      * method.
 2162  
      * </p>
 2163  
      * 
 2164  
      * @see #writeAsync(Callback, BatchedWrite)
 2165  
      */
 2166  
     @Override
 2167  
     public void writeAsync(final Callback<Long> results,
 2168  
             final BatchedWrite.Builder write) throws MongoDbException {
 2169  4
         writeAsync(results, write.build());
 2170  4
     }
 2171  
 
 2172  
     /**
 2173  
      * {@inheritDoc}
 2174  
      * <p>
 2175  
      * Overridden to call the {@link #writeAsync(Callback, BatchedWrite)}
 2176  
      * method.
 2177  
      * </p>
 2178  
      * 
 2179  
      * @see #writeAsync(Callback, BatchedWrite)
 2180  
      */
 2181  
     @Override
 2182  
     public void writeAsync(final LambdaCallback<Long> results,
 2183  
             final BatchedWrite write) throws MongoDbException {
 2184  0
         writeAsync(new LambdaCallbackAdapter<Long>(results), write);
 2185  0
     }
 2186  
 
 2187  
     /**
 2188  
      * {@inheritDoc}
 2189  
      * <p>
 2190  
      * Overridden to call the {@link #writeAsync(LambdaCallback, BatchedWrite)}
 2191  
      * method.
 2192  
      * </p>
 2193  
      * 
 2194  
      * @see #writeAsync(LambdaCallback, BatchedWrite)
 2195  
      */
 2196  
     @Override
 2197  
     public void writeAsync(final LambdaCallback<Long> results,
 2198  
             final BatchedWrite.Builder write) throws MongoDbException {
 2199  0
         writeAsync(results, write.build());
 2200  0
     }
 2201  
 
 2202  
     /**
 2203  
      * Returns the type of lock to use.
 2204  
      * 
 2205  
      * @return The type of lock to use.
 2206  
      */
 2207  
     protected LockType getLockType() {
 2208  141
         return myClient.getConfig().getLockType();
 2209  
     }
 2210  
 
 2211  
 }