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