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