Coverage Report - com.allanbank.mongodb.builder.ComparisonOperator
 
Classes in this File Line Coverage Branch Coverage Complexity
ComparisonOperator
93%
14/15
N/A
1
 
 1  
 /*
 2  
  * #%L
 3  
  * ComparisonOperator.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  
 
 21  
 package com.allanbank.mongodb.builder;
 22  
 
 23  
 import com.allanbank.mongodb.Version;
 24  
 
 25  
 /**
 26  
  * ComparisonOperator provides an enumeration of all possible comparison
 27  
  * operators.
 28  
  * 
 29  
  * @api.yes This enumeration is part of the driver's API. Public and protected
 30  
  *          members will be deprecated for at least 1 non-bugfix release
 31  
  *          (version numbers are <major>.<minor>.<bugfix>)
 32  
  *          before being removed or modified.
 33  
  * @copyright 2012-2013, Allanbank Consulting, Inc., All Rights Reserved
 34  
  */
 35  1
 public enum ComparisonOperator implements Operator {
 36  
     /** The equal operator. Note that this operator does not have a token. */
 37  1
     EQUALS(""),
 38  
 
 39  
     /** The greater than operator. */
 40  1
     GT("$gt"),
 41  
 
 42  
     /** The greater than or equal operator. */
 43  1
     GTE("$gte"),
 44  
 
 45  
     /** The less than operator. */
 46  1
     LT("$lt"),
 47  
 
 48  
     /** The less than or equal operator. */
 49  1
     LTE("$lte"),
 50  
 
 51  
     /** The not equal operator. */
 52  1
     NE("$ne");
 53  
 
 54  
     /** The operator's token to use when sending to the server. */
 55  
     private final String myToken;
 56  
 
 57  
     /** The first MongoDB version to support the operator. */
 58  
     private final Version myVersion;
 59  
 
 60  
     /**
 61  
      * Creates a new ComparisonOperator.
 62  
      * 
 63  
      * @param token
 64  
      *            The token to use when sending to the server.
 65  
      */
 66  
     private ComparisonOperator(final String token) {
 67  6
         this(token, null);
 68  6
     }
 69  
 
 70  
     /**
 71  
      * Creates a new ComparisonOperator.
 72  
      * 
 73  
      * @param token
 74  
      *            The token to use when sending to the server.
 75  
      * @param version
 76  
      *            The first MongoDB version to support the operator.
 77  
      */
 78  6
     private ComparisonOperator(final String token, final Version version) {
 79  6
         myToken = token;
 80  6
         myVersion = version;
 81  6
     }
 82  
 
 83  
     /**
 84  
      * The token for the operator that can be sent to the server.
 85  
      * 
 86  
      * @return The token for the operator.
 87  
      */
 88  
     @Override
 89  
     public String getToken() {
 90  165
         return myToken;
 91  
     }
 92  
 
 93  
     /**
 94  
      * Returns the first MongoDB version to support the operator.
 95  
      * 
 96  
      * @return The first MongoDB version to support the operator. If
 97  
      *         <code>null</code> then the version is not known and can be
 98  
      *         assumed to be all currently supported versions.
 99  
      */
 100  
     @Override
 101  
     public Version getVersion() {
 102  0
         return myVersion;
 103  
     }
 104  
 
 105  
 }