Coverage Report - jaggregate.internal.number.OperableFloat
 
Classes in this File Line Coverage Branch Coverage Complexity
OperableFloat
100%
24/24
100%
7/7
0
OperableFloat$1
100%
2/2
N/A
0
 
 1  
 /*
 2  
  Copyright 2004-2008 Paul R. Holser, Jr.  All rights reserved.
 3  
  Licensed under the Academic Free License version 3.0
 4  
  */
 5  
 
 6  
 package jaggregate.internal.number;
 7  
 
 8  
 /**
 9  
  * Wrapper for a {@code float}.
 10  
  *
 11  
  * @author <a href="mailto:pholser@alumni.rice.edu">Paul Holser</a>
 12  
  * @version $Id: OperableFloat.java,v 1.1 2008/03/26 18:01:26 pholser Exp $
 13  
  */
 14  11041
 public class OperableFloat extends OperableNumber<Float> {
 15  
     private static final long serialVersionUID = -1L;
 16  
 
 17  1
     private static final OperableFloat ONE = new OperableFloat( 1F ) {
 18  
         private static final long serialVersionUID = -1L;
 19  
 
 20  
         @Override
 21  204
         public void incrementBy( OperableNumber<Float> increment ) {
 22  1
             throw new UnsupportedOperationException();
 23  
         }
 24  
     };
 25  
 
 26  
     /**
 27  
      * Creates a wrapper for the given number.
 28  
      *
 29  
      * @param wrapped the wrapped number
 30  
      */
 31  
     public OperableFloat( Float wrapped ) {
 32  8629
         super( wrapped );
 33  8629
     }
 34  
 
 35  
     /**
 36  
      * Creates a wrapper for the given number.
 37  
      *
 38  
      * @param wrapped the wrapped number
 39  
      */
 40  
     public OperableFloat( Integer wrapped ) {
 41  1266
         this( wrapped.floatValue() );
 42  1266
     }
 43  
 
 44  
     /**
 45  
      * {@inheritDoc}
 46  
      */
 47  
     @Override
 48  
     public boolean isZero() {
 49  809
         return unwrapped() == 0F;
 50  
     }
 51  
 
 52  
     /**
 53  
      * {@inheritDoc}
 54  
      */
 55  
     @Override
 56  
     public OperableFloat plus( Float addend ) {
 57  1595
         return new OperableFloat( unwrapped() + addend );
 58  
     }
 59  
 
 60  
     /**
 61  
      * {@inheritDoc}
 62  
      */
 63  
     @Override
 64  
     public OperableFloat plus( int addend ) {
 65  633
         return new OperableFloat( unwrapped() + addend );
 66  
     }
 67  
 
 68  
     /**
 69  
      * {@inheritDoc}
 70  
      */
 71  
     @Override
 72  
     public OperableFloat minus( Float subtrahend ) {
 73  1266
         return new OperableFloat( unwrapped() - subtrahend );
 74  
     }
 75  
 
 76  
     /**
 77  
      * {@inheritDoc}
 78  
      */
 79  
     @Override
 80  
     public OperableFloat times( Float multiplier ) {
 81  633
         return new OperableFloat( unwrapped() * multiplier );
 82  
     }
 83  
 
 84  
     /**
 85  
      * {@inheritDoc}
 86  
      */
 87  
     @Override
 88  
     public OperableFloat times( int multiplier ) {
 89  847
         return new OperableFloat( unwrapped() * multiplier );
 90  
     }
 91  
 
 92  
     /**
 93  
      * {@inheritDoc}
 94  
      */
 95  
     @Override
 96  
     public OperableFloat dividedBy( Float divisor ) {
 97  1266
         return new OperableFloat( (int) ( unwrapped() / divisor ) );
 98  
     }
 99  
 
 100  
     /**
 101  
      * {@inheritDoc}
 102  
      */
 103  
     @Override
 104  
     public OperableFloat modulo( Float divisor ) {
 105  79
         return new OperableFloat( unwrapped() % divisor );
 106  
     }
 107  
 
 108  
     /**
 109  
      * {@inheritDoc}
 110  
      */
 111  
     @Override
 112  
     public boolean isPositive() {
 113  2239
         return unwrapped() > 0F;
 114  
     }
 115  
 
 116  
     /**
 117  
      * {@inheritDoc}
 118  
      */
 119  
     @Override
 120  
     public boolean isNegative() {
 121  1078
         return unwrapped() < 0F;
 122  
     }
 123  
 
 124  
     /**
 125  
      * {@inheritDoc}
 126  
      */
 127  
     @Override
 128  
     public boolean greaterThan( Float comparand ) {
 129  2094
         return unwrapped() > comparand;
 130  
     }
 131  
 
 132  
     /**
 133  
      * {@inheritDoc}
 134  
      */
 135  
     @Override
 136  
     public boolean greaterThanOrEqualTo( Float comparand ) {
 137  385
         return unwrapped() >= comparand;
 138  
     }
 139  
 
 140  
     /**
 141  
      * {@inheritDoc}
 142  
      */
 143  
     @Override
 144  
     public boolean lessThan( Float comparand ) {
 145  1920
         return unwrapped() < comparand;
 146  
     }
 147  
 
 148  
     /**
 149  
      * {@inheritDoc}
 150  
      */
 151  
     @Override
 152  
     public boolean lessThanOrEqualTo( Float comparand ) {
 153  429
         return unwrapped() <= comparand;
 154  
     }
 155  
 
 156  
     /**
 157  
      * {@inheritDoc}
 158  
      */
 159  
     @Override
 160  
     public OperableFloat negated() {
 161  97
         return new OperableFloat( -unwrapped() );
 162  
     }
 163  
 
 164  
     /**
 165  
      * {@inheritDoc}
 166  
      */
 167  
     @Override
 168  
     public void incrementBy( OperableNumber<Float> increment ) {
 169  596
         update( unwrapped() + increment.unwrapped() );
 170  596
     }
 171  
 
 172  
     /**
 173  
      * {@inheritDoc}
 174  
      */
 175  
     @Override
 176  
     public OperableNumber<Float> one() {
 177  181
         return ONE;
 178  
     }
 179  
 }