KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > mule > tck > testmodels > fruit > Orange


1 /*
2  * $Id: Orange.java 3798 2006-11-04 04:07:14Z aperepel $
3  * --------------------------------------------------------------------------------------
4  * Copyright (c) MuleSource, Inc. All rights reserved. http://www.mulesource.com
5  *
6  * The software in this package is published under the terms of the MuleSource MPL
7  * license, a copy of which has been included with this distribution in the
8  * LICENSE.txt file.
9  */

10
11 package org.mule.tck.testmodels.fruit;
12
13 import org.apache.commons.logging.Log;
14 import org.apache.commons.logging.LogFactory;
15 import org.mule.umo.UMOEventContext;
16 import org.mule.umo.UMOException;
17 import org.mule.umo.lifecycle.Callable;
18
19 import java.util.HashMap JavaDoc;
20 import java.util.List JavaDoc;
21 import java.util.Map JavaDoc;
22
23 public class Orange implements Fruit, Callable
24 {
25     /**
26      * Serial version
27      */

28     private static final long serialVersionUID = 2556604671068150589L;
29
30     /**
31      * logger used by this class
32      */

33     private static Log logger = LogFactory.getLog(Orange.class);
34
35     private boolean bitten = false;
36     private Integer JavaDoc segments = new Integer JavaDoc(10);
37     private Double JavaDoc radius = new Double JavaDoc(4.34);
38     private String JavaDoc brand;
39
40     private Map JavaDoc mapProperties;
41
42     private List JavaDoc listProperties;
43
44     private List JavaDoc arrayProperties;
45
46     public Orange()
47     {
48         super();
49     }
50
51     public Orange(Integer JavaDoc segments, Double JavaDoc radius, String JavaDoc brand)
52     {
53         super();
54         this.segments = segments;
55         this.radius = radius;
56         this.brand = brand;
57     }
58
59     public Orange(HashMap JavaDoc props) throws UMOException
60     {
61         setBrand((String JavaDoc)props.get("brand"));
62         setRadius((Double JavaDoc)props.get("radius"));
63         setSegments((Integer JavaDoc)props.get("segments"));
64     }
65
66     public void bite()
67     {
68         bitten = true;
69     }
70
71     public boolean isBitten()
72     {
73         return bitten;
74     }
75
76     public Object JavaDoc onCall(UMOEventContext context) throws UMOException
77     {
78         logger.debug("Orange received an event in UMOCallable.onEvent! Event says: "
79                      + context.getMessageAsString());
80         bite();
81         return null;
82     }
83
84     /**
85      * @return
86      */

87     public String JavaDoc getBrand()
88     {
89         return brand;
90     }
91
92     /**
93      * @return
94      */

95     public Integer JavaDoc getSegments()
96     {
97         return segments;
98     }
99
100     /**
101      * @return
102      */

103     public Double JavaDoc getRadius()
104     {
105         return radius;
106     }
107
108     /**
109      * @param string
110      */

111     public void setBrand(String JavaDoc string)
112     {
113         brand = string;
114     }
115
116     /**
117      * @param integer
118      */

119     public void setSegments(Integer JavaDoc integer)
120     {
121         segments = integer;
122     }
123
124     /**
125      * @param double1
126      */

127     public void setRadius(Double JavaDoc double1)
128     {
129         radius = double1;
130     }
131
132     /**
133      * @return Returns the listProperties.
134      */

135     public List JavaDoc getListProperties()
136     {
137         return listProperties;
138     }
139
140     /**
141      * @param listProperties The listProperties to set.
142      */

143     public void setListProperties(List JavaDoc listProperties)
144     {
145         this.listProperties = listProperties;
146     }
147
148     /**
149      * @return Returns the mapProperties.
150      */

151     public Map JavaDoc getMapProperties()
152     {
153         return mapProperties;
154     }
155
156     /**
157      * @param mapProperties The mapProperties to set.
158      */

159     public void setMapProperties(Map JavaDoc mapProperties)
160     {
161         this.mapProperties = mapProperties;
162     }
163
164     /**
165      * @return Returns the arrayProperties.
166      */

167     public List JavaDoc getArrayProperties()
168     {
169         return arrayProperties;
170     }
171
172     /**
173      * @param arrayProperties The arrayProperties to set.
174      */

175     public void setArrayProperties(List JavaDoc arrayProperties)
176     {
177         this.arrayProperties = arrayProperties;
178     }
179
180     public int hashCode()
181     {
182         final int PRIME = 31;
183         int result = 1;
184         result = PRIME * result + (bitten ? 1231 : 1237);
185         result = PRIME * result + ((brand == null) ? 0 : brand.hashCode());
186         result = PRIME * result + ((radius == null) ? 0 : radius.hashCode());
187         result = PRIME * result + ((segments == null) ? 0 : segments.hashCode());
188         return result;
189     }
190
191     public boolean equals(Object JavaDoc obj)
192     {
193         if (this == obj) return true;
194         if (obj == null) return false;
195         if (getClass() != obj.getClass()) return false;
196         final Orange other = (Orange)obj;
197         if (bitten != other.bitten) return false;
198         if (brand == null)
199         {
200             if (other.brand != null) return false;
201         }
202         else if (!brand.equals(other.brand)) return false;
203         if (radius == null)
204         {
205             if (other.radius != null) return false;
206         }
207         else if (!radius.equals(other.radius)) return false;
208         if (segments == null)
209         {
210             if (other.segments != null) return false;
211         }
212         else if (!segments.equals(other.segments)) return false;
213         return true;
214     }
215
216 }
217
Popular Tags