Coverage report

  %line %branch
net.sf.infrared.agent.util.MutableInteger
30% 
93% 

 1  
 /* 
 2  
  * Copyright 2005 Tavant Technologies and Contributors
 3  
  * 
 4  
  * Licensed under the Apache License, Version 2.0 (the "License")
 5  
  * you may not use this file except in compliance with the License.
 6  
  * You may obtain a copy of the License at
 7  
  *
 8  
  *     http://www.apache.org/licenses/LICENSE-2.0
 9  
  *
 10  
  * Unless required by applicable law or agreed to in writing, software
 11  
  * distributed under the License is distributed on an "AS IS" BASIS,
 12  
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 13  
  * See the License for the specific language governing permissions and
 14  
  * limitations under the License.
 15  
  * 
 16  
  *
 17  
  *
 18  
  * Original Author:  kamal.govindraj (Tavant Technologies)
 19  
  * Contributor(s):   -;
 20  
  *
 21  
  */
 22  
 package net.sf.infrared.agent.util;
 23  
 
 24  
 /**
 25  
  * Object wrapper for int which is mutable. Used in situations where an Object
 26  
  * is required (map key or value) and using the Integer would lead to
 27  
  * unnecessary creation of temporary objects
 28  
  * 
 29  
  * @author kamal.govindraj
 30  
  */
 31  
 public class MutableInteger {
 32  
     private int value;
 33  
 
 34  0
     public MutableInteger() {
 35  0
     }
 36  
 
 37  5
     public MutableInteger(int value) {
 38  5
         this.value = value;
 39  5
     }
 40  
 
 41  0
     public MutableInteger(Integer value) {
 42  0
         this.value = value.intValue();
 43  0
     }
 44  
 
 45  
     public int class="keyword">intValue() {
 46  0
         return value;
 47  
     }
 48  
 
 49  
     public MutableInteger add(int addend) {
 50  0
         value += addend;
 51  0
         return this;
 52  
     }
 53  
 
 54  
     public MutableInteger subtract(int subtractant) {
 55  0
         value -= subtractant;
 56  0
         return this;
 57  
     }
 58  
 
 59  
     public MutableInteger increment() {
 60  9
         value++;
 61  9
         return this;
 62  
     }
 63  
 
 64  
     public MutableInteger decrement() {
 65  9
         value--;
 66  9
         return this;
 67  
     }
 68  
 
 69  
     public boolean isZero() {
 70  18
         return value == 0;
 71  
     }
 72  
 
 73  
     public boolean isPositive() {
 74  0
         return value >= 0;
 75  
     }
 76  
 
 77  
     public boolean isNegative() {
 78  0
         return value < 0;
 79  
     }
 80  
 
 81  
     public boolean isEqual(int value) {
 82  0
         return this.value == value;
 83  
     }
 84  
 
 85  
     /**
 86  
      * @see java.lang.Object#equals(Object)
 87  
      */
 88  
     public boolean equals(Object object) {
 89  0
         if (!(object instanceof MutableInteger)) {
 90  0
             return false;
 91  
         }
 92  0
         MutableInteger rhs = (MutableInteger) object;
 93  0
         return this.value == rhs.value;
 94  
     }
 95  
 
 96  
     /**
 97  
      * @see java.lang.Object#hashCode()
 98  
      */
 99  
     public int hashCode() {
 100  0
         return this.value;
 101  
     }
 102  
 
 103  
     /*
 104  
      * (non-Javadoc)
 105  
      * 
 106  
      * @see java.lang.Object#toString()
 107  
      */
 108  
     public String toString() {
 109  0
         return Integer.toString(value);
 110  
     }
 111  
 
 112  
 }

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