Clover coverage report - Drools - 2.0-rc2
Coverage timestamp: Wed May 11 2005 07:12:26 BST
file stats: LOC: 168   Methods: 9
NCLOC: 63   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
Declaration.java 75% 93.8% 100% 93.1%
coverage coverage
 1    package org.drools.rule;
 2   
 3    /*
 4    * $Id: Declaration.java,v 1.33 2005/02/02 00:23:22 mproctor Exp $
 5    *
 6    * Copyright 2001-2003 (C) The Werken Company. All Rights Reserved.
 7    *
 8    * Redistribution and use of this software and associated documentation
 9    * ("Software"), with or without modification, are permitted provided that the
 10    * following conditions are met:
 11    *
 12    * 1. Redistributions of source code must retain copyright statements and
 13    * notices. Redistributions must also contain a copy of this document.
 14    *
 15    * 2. Redistributions in binary form must reproduce the above copyright notice,
 16    * this list of conditions and the following disclaimer in the documentation
 17    * and/or other materials provided with the distribution.
 18    *
 19    * 3. The name "drools" must not be used to endorse or promote products derived
 20    * from this Software without prior written permission of The Werken Company.
 21    * For written permission, please contact bob@werken.com.
 22    *
 23    * 4. Products derived from this Software may not be called "drools" nor may
 24    * "drools" appear in their names without prior written permission of The Werken
 25    * Company. "drools" is a trademark of The Werken Company.
 26    *
 27    * 5. Due credit should be given to The Werken Company. (http://werken.com/)
 28    *
 29    * THIS SOFTWARE IS PROVIDED BY THE WERKEN COMPANY AND CONTRIBUTORS ``AS IS''
 30    * AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 31    * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 32    * ARE DISCLAIMED. IN NO EVENT SHALL THE WERKEN COMPANY OR ITS CONTRIBUTORS BE
 33    * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 34    * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 35    * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 36    * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 37    * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 38    * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 39    * POSSIBILITY OF SUCH DAMAGE.
 40    *
 41    */
 42   
 43    import java.io.Serializable;
 44   
 45    import org.drools.spi.ObjectType;
 46   
 47    /**
 48    * A typed, named variable for <code>Condition</code> evaluation.
 49    *
 50    * @see ObjectType
 51    * @see org.drools.spi.Condition
 52    *
 53    * @author <a href="mailto:bob@eng.werken.com">bob mcwhirter </a>
 54    * @author <a href="mailto:simon@redhillconsulting.com.au">Simon Harris </a>
 55    */
 56    public class Declaration
 57    implements
 58    Serializable,
 59    Comparable
 60    {
 61    // ------------------------------------------------------------
 62    // Instance members
 63    // ------------------------------------------------------------
 64   
 65    /** The identifier for the variable. */
 66    private final String identifier;
 67   
 68    /** The type of the variable. */
 69    // TODO: Would like to make this final if we can. Requires rejigging the xml
 70    // handler stuff.
 71    private ObjectType objectType;
 72   
 73    /** The index within a rule. */
 74    private final int index;
 75   
 76    // ------------------------------------------------------------
 77    // Constructors
 78    // ------------------------------------------------------------
 79   
 80    /**
 81    * Construct.
 82    *
 83    * @param identifier The name of the variable.
 84    * @param objectType The type of this variable declaration.
 85    * @param order The index within a rule.
 86    */
 87  252 Declaration( String identifier,
 88    ObjectType objectType,
 89    int order )
 90    {
 91  252 this.objectType = objectType;
 92  252 this.identifier = identifier;
 93  252 this.index = order;
 94    }
 95   
 96    // ------------------------------------------------------------
 97    // Instance methods
 98    // ------------------------------------------------------------
 99   
 100    /**
 101    * Retrieve the <code>ObjectType</code>.
 102    *
 103    * @return The object-type.
 104    */
 105  753 public ObjectType getObjectType()
 106    {
 107  753 return this.objectType;
 108    }
 109   
 110    // TODO: Remove this if possible
 111  164 public void setObjectType( ObjectType objectType )
 112    {
 113  164 this.objectType = objectType;
 114    }
 115   
 116    /**
 117    * Retrieve the variable's identifier.
 118    *
 119    * @return The variable's identifier.
 120    */
 121  1343 public String getIdentifier()
 122    {
 123  1343 return this.identifier;
 124    }
 125   
 126  85363 public int getIndex()
 127    {
 128  85363 return this.index;
 129    }
 130   
 131    // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 132   
 133  3 public int compareTo( Object object )
 134    {
 135  3 return this.index - ( ( Declaration ) object ).index;
 136    }
 137   
 138    // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 139   
 140  10 public String toString()
 141    {
 142  10 return "[Declaration: " + this.identifier + "]";
 143    }
 144   
 145  11282 public int hashCode()
 146    {
 147  11282 return this.index;
 148    }
 149   
 150  1690 public boolean equals( Object object )
 151    {
 152  1690 if ( this == object )
 153    {
 154  111 return true;
 155    }
 156   
 157  1579 if ( object == null || getClass( ) != object.getClass( ) )
 158    {
 159  0 return false;
 160    }
 161   
 162  1579 Declaration other = ( Declaration ) object;
 163   
 164  1579 return this.index == other.index
 165    && this.identifier.equals( other.identifier )
 166    && this.objectType.equals( other.objectType );
 167    }
 168    }