| 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 public class Apple implements Fruit, Callable 20 { 21 24 private static final long serialVersionUID = -7631993371500076921L; 25 26 29 private static Log logger = LogFactory.getLog(Apple.class); 30 31 private boolean bitten = false; 32 private boolean washed = false; 33 34 public void wash() 35 { 36 washed = true; 37 } 38 39 public boolean isWashed() 40 { 41 return washed; 42 } 43 44 public void bite() 45 { 46 bitten = true; 47 } 48 49 public boolean isBitten() 50 { 51 return bitten; 52 } 53 54 public Object onCall(UMOEventContext context) throws UMOException 55 { 56 logger.debug("Apple received an event in UMOCallable.onEvent! Event says: " 57 + context.getMessageAsString()); 58 wash(); 59 return null; 60 } 61 62 public boolean equals(Object o) 63 { 64 if (this == o) 65 { 66 return true; 67 } 68 if (o == null || getClass() != o.getClass()) 69 { 70 return false; 71 } 72 73 final Apple apple = (Apple)o; 74 75 if (bitten != apple.bitten) 76 { 77 return false; 78 } 79 if (washed != apple.washed) 80 { 81 return false; 82 } 83 84 return true; 85 } 86 87 public int hashCode() 88 { 89 int result; 90 result = (bitten ? 1 : 0); 91 result = 29 * result + (washed ? 1 : 0); 92 return result; 93 } 94 } 95 | Popular Tags |