1 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 ; 20 import java.util.List ; 21 import java.util.Map ; 22 23 public class Orange implements Fruit, Callable 24 { 25 28 private static final long serialVersionUID = 2556604671068150589L; 29 30 33 private static Log logger = LogFactory.getLog(Orange.class); 34 35 private boolean bitten = false; 36 private Integer segments = new Integer (10); 37 private Double radius = new Double (4.34); 38 private String brand; 39 40 private Map mapProperties; 41 42 private List listProperties; 43 44 private List arrayProperties; 45 46 public Orange() 47 { 48 super(); 49 } 50 51 public Orange(Integer segments, Double radius, String brand) 52 { 53 super(); 54 this.segments = segments; 55 this.radius = radius; 56 this.brand = brand; 57 } 58 59 public Orange(HashMap props) throws UMOException 60 { 61 setBrand((String )props.get("brand")); 62 setRadius((Double )props.get("radius")); 63 setSegments((Integer )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 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 87 public String getBrand() 88 { 89 return brand; 90 } 91 92 95 public Integer getSegments() 96 { 97 return segments; 98 } 99 100 103 public Double getRadius() 104 { 105 return radius; 106 } 107 108 111 public void setBrand(String string) 112 { 113 brand = string; 114 } 115 116 119 public void setSegments(Integer integer) 120 { 121 segments = integer; 122 } 123 124 127 public void setRadius(Double double1) 128 { 129 radius = double1; 130 } 131 132 135 public List getListProperties() 136 { 137 return listProperties; 138 } 139 140 143 public void setListProperties(List listProperties) 144 { 145 this.listProperties = listProperties; 146 } 147 148 151 public Map getMapProperties() 152 { 153 return mapProperties; 154 } 155 156 159 public void setMapProperties(Map mapProperties) 160 { 161 this.mapProperties = mapProperties; 162 } 163 164 167 public List getArrayProperties() 168 { 169 return arrayProperties; 170 } 171 172 175 public void setArrayProperties(List 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 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 |