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 org.apache.commons.logging.Log;
14 import org.apache.commons.logging.LogFactory;
15
16 public class Apple implements Fruit, Callable
17 {
18
19
20
21 private static final long serialVersionUID = -7631993371500076921L;
22
23
24
25
26 private static final Log logger = LogFactory.getLog(Apple.class);
27
28 private boolean bitten = false;
29 private boolean washed = false;
30
31 private FruitCleaner cleaner;
32
33 public Apple()
34 {
35 }
36
37 public Apple(boolean bitten)
38 {
39 this.bitten = bitten;
40 }
41
42 public void wash()
43 {
44 if (cleaner != null)
45 {
46 cleaner.wash(this);
47 }
48 washed = true;
49 }
50
51 public void polish()
52 {
53 cleaner.polish(this);
54 }
55
56 public boolean isWashed()
57 {
58 return washed;
59 }
60
61 public void bite()
62 {
63 bitten = true;
64 }
65
66 public boolean isBitten()
67 {
68 return bitten;
69 }
70
71 public Object onCall(MuleEventContext context) throws MuleException
72 {
73 logger.debug("Apple received an event in Callable.onEvent! MuleEvent says: "
74 + context.getMessageAsString());
75 wash();
76 return null;
77 }
78
79
80 public FruitCleaner getAppleCleaner()
81 {
82 return cleaner;
83 }
84
85 public void setAppleCleaner(FruitCleaner cleaner)
86 {
87 this.cleaner = cleaner;
88 }
89
90 public Object methodReturningNull()
91 {
92 return null;
93 }
94
95 public boolean equals(Object o)
96 {
97 if (this == o)
98 {
99 return true;
100 }
101 if (o == null || getClass() != o.getClass())
102 {
103 return false;
104 }
105
106 final Apple apple = (Apple) o;
107
108 if (bitten != apple.bitten)
109 {
110 return false;
111 }
112 if (washed != apple.washed)
113 {
114 return false;
115 }
116
117 return true;
118 }
119
120 public int hashCode()
121 {
122 int result;
123 result = (bitten ? 1 : 0);
124 result = 29 * result + (washed ? 1 : 0);
125 return result;
126 }
127
128 public String toString()
129 {
130 return "Just an apple.";
131 }
132
133 public void setBitten(boolean bitten)
134 {
135 this.bitten = bitten;
136 }
137
138 public void setWashed(boolean washed)
139 {
140 this.washed = washed;
141 }
142 }