Coverage report

  %line %branch
org.apache.torque.util.SqlEnum
95% 
100% 

 1  
 package org.apache.torque.util;
 2  
 
 3  
 /*
 4  
  * Licensed to the Apache Software Foundation (ASF) under one
 5  
  * or more contributor license agreements.  See the NOTICE file
 6  
  * distributed with this work for additional information
 7  
  * regarding copyright ownership.  The ASF licenses this file
 8  
  * to you under the Apache License, Version 2.0 (the
 9  
  * "License"); you may not use this file except in compliance
 10  
  * with the License.  You may obtain a copy of the License at
 11  
  *
 12  
  *   http://www.apache.org/licenses/LICENSE-2.0
 13  
  *
 14  
  * Unless required by applicable law or agreed to in writing,
 15  
  * software distributed under the License is distributed on an
 16  
  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 17  
  * KIND, either express or implied.  See the License for the
 18  
  * specific language governing permissions and limitations
 19  
  * under the License.
 20  
  */
 21  
 
 22  
 /**
 23  
  * A typesafe enum of SQL string fragments.  Used by Criteria and SqlExpression
 24  
  * to build queries.  Criteria also makes most of the constants available
 25  
  * in order to specify a criterion.
 26  
  *
 27  
  * @author <a href="mailto:jmcnally@collab.net"></a>
 28  
  * @author <a href="mailto:fischer@seitenbau.de">Thomas Fischer</a>
 29  
  * @version $Id: SqlEnum.java 473821 2006-11-11 22:37:25Z tv $
 30  
  * @since 3.0
 31  
  */
 32  
 public class SqlEnum implements java.io.Serializable
 33  
 {
 34  
     /**
 35  
      * Serial version
 36  
      */
 37  
     private static final long serialVersionUID = 5963149836513364800L;
 38  
 
 39  
     private final String s;
 40  
 
 41  
     private SqlEnum(String s)
 42  928
     {
 43  928
         this.s = s;
 44  928
     }
 45  
 
 46  
     public final String toString()
 47  
     {
 48  1072
         return s;
 49  
     }
 50  
 
 51  32
     public static final SqlEnum EQUAL =
 52  
         new SqlEnum("=");
 53  32
     public static final SqlEnum NOT_EQUAL =
 54  
             new SqlEnum("<>");
 55  32
     public static final SqlEnum ALT_NOT_EQUAL =
 56  
         new SqlEnum("!=");
 57  32
     public static final SqlEnum GREATER_THAN =
 58  
         new SqlEnum(">");
 59  32
     public static final SqlEnum LESS_THAN =
 60  
         new SqlEnum("<");
 61  32
     public static final SqlEnum GREATER_EQUAL =
 62  
         new SqlEnum(">=");
 63  32
     public static final SqlEnum LESS_EQUAL =
 64  
         new SqlEnum("<=");
 65  32
     public static final SqlEnum LIKE =
 66  
         new SqlEnum(" LIKE ");
 67  32
     public static final SqlEnum NOT_LIKE =
 68  
         new SqlEnum(" NOT LIKE ");
 69  32
     public static final SqlEnum ILIKE =
 70  
         new SqlEnum(" ILIKE ");
 71  32
     public static final SqlEnum NOT_ILIKE =
 72  
         new SqlEnum(" NOT ILIKE ");
 73  32
     public static final SqlEnum IN =
 74  
         new SqlEnum(" IN ");
 75  32
     public static final SqlEnum NOT_IN =
 76  
         new SqlEnum(" NOT IN ");
 77  32
     public static final SqlEnum CUSTOM =
 78  
         new SqlEnum("CUSTOM");
 79  32
     public static final SqlEnum JOIN =
 80  
         new SqlEnum("JOIN");
 81  32
     public static final SqlEnum DISTINCT =
 82  
         new SqlEnum("DISTINCT ");
 83  32
     public static final SqlEnum ALL =
 84  
         new SqlEnum("ALL ");
 85  32
     public static final SqlEnum ASC =
 86  
         new SqlEnum("ASC");
 87  32
     public static final SqlEnum DESC =
 88  
         new SqlEnum("DESC");
 89  32
     public static final SqlEnum ISNULL =
 90  
         new SqlEnum(" IS NULL ");
 91  32
     public static final SqlEnum ISNOTNULL =
 92  
         new SqlEnum(" IS NOT NULL ");
 93  32
     public static final SqlEnum CURRENT_DATE =
 94  
         new SqlEnum("CURRENT_DATE");
 95  32
     public static final SqlEnum CURRENT_TIME =
 96  
         new SqlEnum("CURRENT_TIME");
 97  32
     public static final SqlEnum LEFT_JOIN =
 98  
         new SqlEnum(" LEFT JOIN ");
 99  32
     public static final SqlEnum RIGHT_JOIN =
 100  
         new SqlEnum(" RIGHT JOIN ");
 101  32
     public static final SqlEnum INNER_JOIN =
 102  
         new SqlEnum(" INNER JOIN ");
 103  32
     public static final SqlEnum ON =
 104  
         new SqlEnum(" ON ");
 105  32
     public static final SqlEnum AS =
 106  
         new SqlEnum(" AS ");
 107  32
     public static final SqlEnum ESCAPE =
 108  
         new SqlEnum(" ESCAPE ");
 109  
 
 110  
     /**
 111  
      * returns whether o is the same SqlEnum as this object.
 112  
      * Two SqlEnums are considered equal if they contain the same String.
 113  
      * @param o the object to compare the SqlEnum with.
 114  
      */
 115  
     public boolean equals(Object o)
 116  
     {
 117  5456
         if (o == null)
 118  
         {
 119  0
             return false;
 120  
         }
 121  
 
 122  5456
         if (!(o instanceof SqlEnum))
 123  
         {
 124  0
             return false;
 125  
         }
 126  
 
 127  5456
         SqlEnum otherEnum = (SqlEnum) o;
 128  
 
 129  
 
 130  
         // both null: true
 131  
         // other null, this not null: false
 132  
         // else compare
 133  5456
         return (otherEnum.s == null)
 134  
                 ? (s == null)
 135  
                 : otherEnum.s.equals(s);
 136  
     }
 137  
 
 138  
     /**
 139  
      * returns a hashcode for this object which is consistent with equals()
 140  
      */
 141  
     public int hashCode()
 142  
     {
 143  192
         return (s == null)
 144  
                 ? 0
 145  
                 : s.hashCode();
 146  
     }
 147  
 }

This report is generated by jcoverage, Maven and Maven JCoverage Plugin.