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