Clover Coverage Report - perfectjpattern(Aggregated)
Coverage timestamp: Sat Feb 28 2009 14:35:07 CET
../../../../img/srcFileCovDistChart10.png 0% of files have more coverage
23   201   15   1.92
8   91   0.65   12
12     1.25  
1    
 
  Product       Line # 32 23 0% 15 1 97.7% 0.9767442
 
  (4)
 
1    //----------------------------------------------------------------------
2    //
3    // PerfectJPattern: "Design patterns are good but components are better!"
4    // Product.java Copyright (c) 2009 Giovanni Azua Garcia
5    // bravegag@hotmail.com
6    //
7    // This program is free software; you can redistribute it and/or
8    // modify it under the terms of the GNU General Public License
9    // as published by the Free Software Foundation; either version 3
10    // of the License, or (at your option) any later version.
11    //
12    // This program 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
15    // GNU General Public License for more details.
16    //
17    // You should have received a copy of the GNU General Public License
18    // along with this program; if not, see <http://www.gnu.org/licenses/>.
19    //
20    //----------------------------------------------------------------------
21    package org.perfectjpattern.example.datamodel;
22   
23    import java.util.*;
24   
25    /**
26    * Product Data model object
27    *
28    * @author <a href="mailto:bravegag@hotmail.com">Giovanni Azua</a>
29    * @version $ $Date: Dec 5, 2008 2:59:45 AM $
30    */
31    public
 
32    class Product
33    {
34    //------------------------------------------------------------------------
35    // public
36    //------------------------------------------------------------------------
 
37  14 toggle public
38    Product()
39    {
40    // do nothing
41    }
42   
43    //------------------------------------------------------------------------
 
44  13 toggle public
45    Product(String aName, double aListPrice)
46    {
47  13 theName = aName;
48  13 theListPrice = aListPrice;
49  13 theOrders = new HashSet<Order>();
50    }
51   
52    //------------------------------------------------------------------------
53    /**
54    * Returns the id
55    *
56    * @return the id
57    */
 
58  77 toggle public long
59    getId()
60    {
61  77 return theId;
62    }
63   
64    //------------------------------------------------------------------------
65    /**
66    * Sets the id of the person
67    *
68    * @param anId the id to set
69    */
 
70  19 toggle public void
71    setId(long anId)
72    {
73  19 theId = anId;
74    }
75   
76    //------------------------------------------------------------------------
77    /**
78    * Returns the name
79    *
80    * @return the name
81    */
 
82  64 toggle public String
83    getName()
84    {
85  64 return theName;
86    }
87   
88    //------------------------------------------------------------------------
89    /**
90    * Sets the name of the person
91    *
92    * @param anName the name to set
93    */
 
94  19 toggle public void
95    setName(String anName)
96    {
97  19 theName = anName;
98    }
99   
100    //------------------------------------------------------------------------
101    /**
102    * Returns the listPrice
103    *
104    * @return the listPrice
105    */
 
106  54 toggle public double
107    getListPrice()
108    {
109  54 return theListPrice;
110    }
111   
112    //------------------------------------------------------------------------
113    /**
114    * Sets the listPrice
115    *
116    * @param aListPrice the listPrice to set
117    */
 
118  19 toggle public void
119    setListPrice(double aListPrice)
120    {
121  19 theListPrice = aListPrice;
122    }
123   
124    //------------------------------------------------------------------------
125    /**
126    * Returns the orders
127    *
128    * @return the orders
129    */
 
130  89 toggle public Set<Order>
131    getOrders()
132    {
133  89 return theOrders;
134    }
135   
136    //------------------------------------------------------------------------
137    /**
138    * Sets the orders
139    *
140    * @param anOrders the orders to set
141    */
 
142  19 toggle public void
143    setOrders(Set<Order> anOrders)
144    {
145  19 theOrders = anOrders;
146    }
147   
148    //------------------------------------------------------------------------
149    /**
150    * {@inheritDoc}
151    */
 
152  74 toggle @Override
153    public final int
154    hashCode()
155    {
156  74 final int myPrime = 31;
157   
158  74 int myResult = 1;
159  74 myResult = myPrime * myResult + ((theName == null)
160    ? 0 : theName.hashCode());
161   
162  74 return myResult;
163    }
164   
165    //------------------------------------------------------------------------
166    /**
167    * {@inheritDoc}
168    */
 
169  5 toggle @Override
170    public final boolean
171    equals(Object anAnother)
172    {
173  5 if (this == anAnother)
174    {
175  1 return true;
176    }
177   
178  4 if (anAnother == null)
179    {
180  1 return false;
181    }
182   
183  3 if (!(anAnother instanceof Product))
184    {
185  1 return false;
186    }
187   
188  2 final Product myAnother = (Product) anAnother;
189  2 return (getName() == null && myAnother.getName() == null) ||
190    (getName() != null && myAnother.getName() != null
191    && getName().equals(myAnother.getName()));
192    }
193   
194    //------------------------------------------------------------------------
195    // members
196    //------------------------------------------------------------------------
197    private long theId;
198    private String theName;
199    private double theListPrice;
200    private Set<Order> theOrders;
201    }