Coverage Report - com.allanbank.mongodb.client.message.ParallelScanCommand
 
Classes in this File Line Coverage Branch Coverage Complexity
ParallelScanCommand
100%
15/15
100%
6/6
1.6
 
 1  
 /*
 2  
  * #%L
 3  
  * ParallelScanCommand.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.message;
 21  
 
 22  
 import com.allanbank.mongodb.ReadPreference;
 23  
 import com.allanbank.mongodb.Version;
 24  
 import com.allanbank.mongodb.bson.Document;
 25  
 import com.allanbank.mongodb.builder.ParallelScan;
 26  
 import com.allanbank.mongodb.client.VersionRange;
 27  
 
 28  
 /**
 29  
  * Helper class for the {@code parallelCollectionScan} commands.
 30  
  * 
 31  
  * @api.no This class is <b>NOT</b> part of the drivers API. This class may be
 32  
  *         mutated in incompatible ways between any two releases of the driver.
 33  
  * @copyright 2014, Allanbank Consulting, Inc., All Rights Reserved
 34  
  */
 35  
 public class ParallelScanCommand extends Command implements CursorableMessage {
 36  
 
 37  
     /**
 38  
      * The first version of MongoDB to support the
 39  
      * {@code parallelCollectionScan} command.
 40  
      */
 41  1
     public static final Version REQUIRED_VERSION = ParallelScan.REQUIRED_VERSION;
 42  
 
 43  
     /** The original request. */
 44  
     private final ParallelScan myCommand;
 45  
 
 46  
     /**
 47  
      * Create a new ParallelScanCommand.
 48  
      * 
 49  
      * @param command
 50  
      *            The original request.
 51  
      * @param databaseName
 52  
      *            The name of the database.
 53  
      * @param collectionName
 54  
      *            The name of the collection to run the scan on.
 55  
      * @param commandDocument
 56  
      *            The command document containing the command and options.
 57  
      * @param readPreference
 58  
      *            The read preference for the command.
 59  
      */
 60  
     public ParallelScanCommand(final ParallelScan command,
 61  
             final String databaseName, final String collectionName,
 62  
             final Document commandDocument, final ReadPreference readPreference) {
 63  61
         super(databaseName, collectionName, commandDocument, readPreference,
 64  
                 VersionRange.minimum(REQUIRED_VERSION));
 65  
 
 66  61
         myCommand = command;
 67  61
     }
 68  
 
 69  
     /**
 70  
      * Determines if the passed object is of this same type as this object and
 71  
      * if so that its fields are equal.
 72  
      * 
 73  
      * @param object
 74  
      *            The object to compare to.
 75  
      * 
 76  
      * @see java.lang.Object#equals(java.lang.Object)
 77  
      */
 78  
     @Override
 79  
     public boolean equals(final Object object) {
 80  489
         boolean result = false;
 81  489
         if (this == object) {
 82  27
             result = true;
 83  
         }
 84  462
         else if ((object != null) && (getClass() == object.getClass())) {
 85  381
             result = super.equals(object);
 86  
         }
 87  489
         return result;
 88  
     }
 89  
 
 90  
     /**
 91  
      * {@inheritDoc}
 92  
      * <p>
 93  
      * Overridden to return 0 or the default batch size.
 94  
      * </p>
 95  
      */
 96  
     @Override
 97  
     public int getBatchSize() {
 98  4
         return myCommand.getBatchSize();
 99  
     }
 100  
 
 101  
     /**
 102  
      * {@inheritDoc}
 103  
      * <p>
 104  
      * Overridden to return 0 or no limit.
 105  
      * </p>
 106  
      */
 107  
     @Override
 108  
     public int getLimit() {
 109  4
         return 0;
 110  
     }
 111  
 
 112  
     /**
 113  
      * Computes a reasonable hash code.
 114  
      * 
 115  
      * @return The hash code value.
 116  
      */
 117  
     @Override
 118  
     public int hashCode() {
 119  756
         int result = 1;
 120  756
         result = (31 * result) + super.hashCode();
 121  756
         return result;
 122  
     }
 123  
 }