1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
package org.mule.tck.testmodels.fruit; |
12 | |
|
13 | |
import org.mule.umo.UMOEventContext; |
14 | |
import org.mule.umo.UMOException; |
15 | |
import org.mule.umo.lifecycle.Callable; |
16 | |
|
17 | |
import java.util.HashMap; |
18 | |
import java.util.List; |
19 | |
import java.util.Map; |
20 | |
|
21 | |
import org.apache.commons.logging.Log; |
22 | |
import org.apache.commons.logging.LogFactory; |
23 | |
|
24 | |
public class Orange implements Fruit, Callable |
25 | |
{ |
26 | |
|
27 | |
|
28 | |
|
29 | |
private static final long serialVersionUID = 2556604671068150589L; |
30 | |
|
31 | |
|
32 | |
|
33 | |
|
34 | 4 | private static final Log logger = LogFactory.getLog(Orange.class); |
35 | |
|
36 | 68 | private boolean bitten = false; |
37 | 68 | private Integer segments = new Integer(10); |
38 | 68 | private Double radius = new Double(4.34); |
39 | |
private String brand; |
40 | |
|
41 | |
private FruitCleaner cleaner; |
42 | |
|
43 | |
private Map mapProperties; |
44 | |
|
45 | |
private List listProperties; |
46 | |
|
47 | |
private List arrayProperties; |
48 | |
|
49 | |
public Orange() |
50 | |
{ |
51 | 44 | super(); |
52 | 44 | } |
53 | |
|
54 | |
public Orange(Integer segments, Double radius, String brand) |
55 | |
{ |
56 | 24 | super(); |
57 | 24 | this.segments = segments; |
58 | 24 | this.radius = radius; |
59 | 24 | this.brand = brand; |
60 | 24 | } |
61 | |
|
62 | |
public Orange(HashMap props) throws UMOException |
63 | 0 | { |
64 | 0 | setBrand((String) props.get("brand")); |
65 | 0 | setRadius((Double) props.get("radius")); |
66 | 0 | setSegments((Integer) props.get("segments")); |
67 | 0 | } |
68 | |
|
69 | |
public void bite() |
70 | |
{ |
71 | 0 | bitten = true; |
72 | 0 | } |
73 | |
|
74 | |
public boolean isBitten() |
75 | |
{ |
76 | 0 | return bitten; |
77 | |
} |
78 | |
|
79 | |
public Object onCall(UMOEventContext context) throws UMOException |
80 | |
{ |
81 | 0 | logger.debug("Orange received an event in UMOCallable.onEvent! Event says: " |
82 | |
+ context.getMessageAsString()); |
83 | 0 | bite(); |
84 | 0 | return null; |
85 | |
} |
86 | |
|
87 | |
|
88 | |
|
89 | |
|
90 | |
public String getBrand() |
91 | |
{ |
92 | 0 | return brand; |
93 | |
} |
94 | |
|
95 | |
|
96 | |
|
97 | |
|
98 | |
public Integer getSegments() |
99 | |
{ |
100 | 0 | return segments; |
101 | |
} |
102 | |
|
103 | |
|
104 | |
|
105 | |
|
106 | |
public Double getRadius() |
107 | |
{ |
108 | 0 | return radius; |
109 | |
} |
110 | |
|
111 | |
|
112 | |
|
113 | |
|
114 | |
public void setBrand(String string) |
115 | |
{ |
116 | 0 | brand = string; |
117 | 0 | } |
118 | |
|
119 | |
|
120 | |
|
121 | |
|
122 | |
public void setSegments(Integer integer) |
123 | |
{ |
124 | 0 | segments = integer; |
125 | 0 | } |
126 | |
|
127 | |
|
128 | |
|
129 | |
|
130 | |
public void setRadius(Double double1) |
131 | |
{ |
132 | 0 | radius = double1; |
133 | 0 | } |
134 | |
|
135 | |
|
136 | |
|
137 | |
|
138 | |
public List getListProperties() |
139 | |
{ |
140 | 0 | return listProperties; |
141 | |
} |
142 | |
|
143 | |
|
144 | |
|
145 | |
|
146 | |
public void setListProperties(List listProperties) |
147 | |
{ |
148 | 0 | this.listProperties = listProperties; |
149 | 0 | } |
150 | |
|
151 | |
|
152 | |
|
153 | |
|
154 | |
public Map getMapProperties() |
155 | |
{ |
156 | 0 | return mapProperties; |
157 | |
} |
158 | |
|
159 | |
|
160 | |
|
161 | |
|
162 | |
public void setMapProperties(Map mapProperties) |
163 | |
{ |
164 | 0 | this.mapProperties = mapProperties; |
165 | 0 | } |
166 | |
|
167 | |
|
168 | |
|
169 | |
|
170 | |
public List getArrayProperties() |
171 | |
{ |
172 | 0 | return arrayProperties; |
173 | |
} |
174 | |
|
175 | |
|
176 | |
|
177 | |
|
178 | |
public void setArrayProperties(List arrayProperties) |
179 | |
{ |
180 | 0 | this.arrayProperties = arrayProperties; |
181 | 0 | } |
182 | |
|
183 | |
|
184 | |
public FruitCleaner getCleaner() |
185 | |
{ |
186 | 0 | return cleaner; |
187 | |
} |
188 | |
|
189 | |
public void setCleaner(FruitCleaner cleaner) |
190 | |
{ |
191 | 0 | this.cleaner = cleaner; |
192 | 0 | } |
193 | |
|
194 | |
public void wash() |
195 | |
{ |
196 | 0 | cleaner.wash(this); |
197 | 0 | } |
198 | |
|
199 | |
public void polish() |
200 | |
{ |
201 | 0 | cleaner.polish(this); |
202 | 0 | } |
203 | |
|
204 | |
public int hashCode() |
205 | |
{ |
206 | 0 | final int prime = 31; |
207 | 0 | int result = 1; |
208 | 0 | result = prime * result + (bitten ? 1231 : 1237); |
209 | 0 | result = prime * result + ((brand == null) ? 0 : brand.hashCode()); |
210 | 0 | result = prime * result + ((radius == null) ? 0 : radius.hashCode()); |
211 | 0 | result = prime * result + ((segments == null) ? 0 : segments.hashCode()); |
212 | 0 | return result; |
213 | |
} |
214 | |
|
215 | |
public boolean equals(Object obj) |
216 | |
{ |
217 | 8 | if (this == obj) |
218 | |
{ |
219 | 0 | return true; |
220 | |
} |
221 | 8 | if (obj == null) |
222 | |
{ |
223 | 0 | return false; |
224 | |
} |
225 | 8 | if (getClass() != obj.getClass()) |
226 | |
{ |
227 | 0 | return false; |
228 | |
} |
229 | 8 | final Orange other = (Orange) obj; |
230 | 8 | if (bitten != other.bitten) |
231 | |
{ |
232 | 0 | return false; |
233 | |
} |
234 | 8 | if (brand == null) |
235 | |
{ |
236 | 0 | if (other.brand != null) |
237 | |
{ |
238 | 0 | return false; |
239 | |
} |
240 | |
} |
241 | 8 | else if (!brand.equals(other.brand)) |
242 | |
{ |
243 | 0 | return false; |
244 | |
} |
245 | 8 | if (radius == null) |
246 | |
{ |
247 | 0 | if (other.radius != null) |
248 | |
{ |
249 | 0 | return false; |
250 | |
} |
251 | |
} |
252 | 8 | else if (!radius.equals(other.radius)) |
253 | |
{ |
254 | 0 | return false; |
255 | |
} |
256 | 8 | if (segments == null) |
257 | |
{ |
258 | 0 | if (other.segments != null) |
259 | |
{ |
260 | 0 | return false; |
261 | |
} |
262 | |
} |
263 | 8 | else if (!segments.equals(other.segments)) |
264 | |
{ |
265 | 0 | return false; |
266 | |
} |
267 | 8 | return true; |
268 | |
} |
269 | |
|
270 | |
} |