1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
|
21 |
|
package org.perfectjpattern.example.datamodel; |
22 |
|
|
23 |
|
import java.util.*; |
24 |
|
|
25 |
|
|
26 |
|
|
27 |
|
|
28 |
|
@author |
29 |
|
@version |
30 |
|
|
31 |
|
public |
|
|
| 97.7% |
Uncovered Elements: 1 (43) |
Complexity: 15 |
Complexity Density: 0.65 |
|
32 |
|
class Product |
33 |
|
{ |
34 |
|
|
35 |
|
|
36 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
|
37 |
14
|
public ... |
38 |
|
Product() |
39 |
|
{ |
40 |
|
|
41 |
|
} |
42 |
|
|
43 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0.33 |
|
44 |
13
|
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 |
|
|
55 |
|
|
56 |
|
@return |
57 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
58 |
77
|
public long ... |
59 |
|
getId() |
60 |
|
{ |
61 |
77
|
return theId; |
62 |
|
} |
63 |
|
|
64 |
|
|
65 |
|
|
66 |
|
|
67 |
|
|
68 |
|
@param |
69 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
70 |
19
|
public void ... |
71 |
|
setId(long anId) |
72 |
|
{ |
73 |
19
|
theId = anId; |
74 |
|
} |
75 |
|
|
76 |
|
|
77 |
|
|
78 |
|
|
79 |
|
|
80 |
|
@return |
81 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
82 |
64
|
public String ... |
83 |
|
getName() |
84 |
|
{ |
85 |
64
|
return theName; |
86 |
|
} |
87 |
|
|
88 |
|
|
89 |
|
|
90 |
|
|
91 |
|
|
92 |
|
@param |
93 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
94 |
19
|
public void ... |
95 |
|
setName(String anName) |
96 |
|
{ |
97 |
19
|
theName = anName; |
98 |
|
} |
99 |
|
|
100 |
|
|
101 |
|
|
102 |
|
|
103 |
|
|
104 |
|
@return |
105 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
106 |
54
|
public double ... |
107 |
|
getListPrice() |
108 |
|
{ |
109 |
54
|
return theListPrice; |
110 |
|
} |
111 |
|
|
112 |
|
|
113 |
|
|
114 |
|
|
115 |
|
|
116 |
|
@param |
117 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
118 |
19
|
public void ... |
119 |
|
setListPrice(double aListPrice) |
120 |
|
{ |
121 |
19
|
theListPrice = aListPrice; |
122 |
|
} |
123 |
|
|
124 |
|
|
125 |
|
|
126 |
|
|
127 |
|
|
128 |
|
@return |
129 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
130 |
89
|
public Set<Order> ... |
131 |
|
getOrders() |
132 |
|
{ |
133 |
89
|
return theOrders; |
134 |
|
} |
135 |
|
|
136 |
|
|
137 |
|
|
138 |
|
|
139 |
|
|
140 |
|
@param |
141 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
142 |
19
|
public void ... |
143 |
|
setOrders(Set<Order> anOrders) |
144 |
|
{ |
145 |
19
|
theOrders = anOrders; |
146 |
|
} |
147 |
|
|
148 |
|
|
149 |
|
|
150 |
|
@inheritDoc |
151 |
|
|
|
|
| 83.3% |
Uncovered Elements: 1 (6) |
Complexity: 1 |
Complexity Density: 0.25 |
|
152 |
74
|
@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 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (14) |
Complexity: 4 |
Complexity Density: 0.5 |
|
169 |
5
|
@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 |
|
|
196 |
|
|
197 |
|
private long theId; |
198 |
|
private String theName; |
199 |
|
private double theListPrice; |
200 |
|
private Set<Order> theOrders; |
201 |
|
} |