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