Clover coverage report -
Coverage timestamp: Thu Jul 5 2007 20:02:32 EDT
file stats: LOC: 100   Methods: 9
NCLOC: 54   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
EnumPlanet.java - 41.7% 44.4% 42.9%
coverage coverage
 1    /*
 2    * JBoss, Home of Professional Open Source.
 3    * Copyright 2006, Red Hat Middleware LLC, and individual contributors
 4    * as indicated by the @author tags. See the copyright.txt file in the
 5    * distribution for a full listing of individual contributors.
 6    *
 7    * This is free software; you can redistribute it and/or modify it
 8    * under the terms of the GNU Lesser General Public License as
 9    * published by the Free Software Foundation; either version 2.1 of
 10    * the License, or (at your option) any later version.
 11    *
 12    * This software is distributed in the hope that it will be useful,
 13    * but WITHOUT ANY WARRANTY; without even the implied warranty of
 14    * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 15    * Lesser General Public License for more details.
 16    *
 17    * You should have received a copy of the GNU Lesser General Public
 18    * License along with this software; if not, write to the Free
 19    * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
 20    * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
 21    */
 22   
 23    package org.jboss.cache.pojo.test;
 24   
 25    /**
 26    * Test class for PojoCache Enum.
 27    *
 28    * @version $Revision: 1.1 $
 29    * <p>Below is the annotation that signifies this class is "prepared" under JBossAop. This is used in
 30    * conjunction with a special jboss-aop.xml (supplied by JBossCache). In addition, this is JDK1.4 style,
 31    * so a annoc Ant build target is needed to pre-compile it.</p>
 32    * <p>To use this approach, just apply this line to your pojo and run annoc (and possibly aopc).</p>
 33    */
 34    // We are using JDK1.5 annotation.
 35    @org.jboss.cache.pojo.annotation.Replicable
 36    public enum EnumPlanet
 37    {
 38    MERCURY(3.303e+23, 2.4397e6),
 39    VENUS(4.869e+24, 6.0518e6),
 40    EARTH(5.976e+24, 6.37814e6),
 41    MARS(6.421e+23, 3.3972e6),
 42    JUPITER(1.9e+27, 7.1492e7),
 43    SATURN(5.688e+26, 6.0268e7),
 44    URANUS(8.686e+25, 2.5559e7),
 45    NEPTUNE(1.024e+26, 2.4746e7);
 46   
 47    private double mass; // in kilograms
 48    private double radius; // in meters
 49   
 50    // Need this for PojoCache. Can be private as well!
 51  0 EnumPlanet() {;}
 52   
 53  8 EnumPlanet(double mass, double radius)
 54    {
 55  8 this.mass = mass;
 56  8 this.radius = radius;
 57    }
 58   
 59  2 public double mass()
 60    {
 61  2 return mass;
 62    }
 63   
 64  0 public double radius()
 65    {
 66  0 return radius;
 67    }
 68   
 69  1 public void setMass(double mass)
 70    {
 71  1 this.mass = mass;
 72    }
 73   
 74  0 public void setRadius(double radius)
 75    {
 76  0 this.radius = radius;
 77    }
 78   
 79    // universal gravitational constant (m3 kg-1 s-2)
 80    public static final double G = 6.67300E-11;
 81   
 82  1 public double surfaceGravity()
 83    {
 84  1 return G * mass / (radius * radius);
 85    }
 86   
 87  0 public double surfaceWeight(double otherMass)
 88    {
 89  0 return otherMass * surfaceGravity();
 90    }
 91   
 92  0 public static void main(String[] args)
 93    {
 94  0 double earthWeight = Double.parseDouble(args[0]);
 95  0 double mass = earthWeight / EARTH.surfaceGravity();
 96  0 for (EnumPlanet p : EnumPlanet.values())
 97  0 System.out.printf("Weight on %s is %f%n",
 98    p, p.surfaceWeight(mass));
 99    }
 100    }