View Javadoc
1   /*
2    * Copyright (c) MuleSoft, Inc.  All rights reserved.  http://www.mulesoft.com
3    * The software in this package is published under the terms of the CPAL v1.0
4    * license, a copy of which has been included with this distribution in the
5    * LICENSE.txt file.
6    */
7   package org.mule.tck.testmodels.fruit;
8   
9   import org.mule.api.MuleEventContext;
10  
11  /**
12   * A test object not implementing Callable, but having a matching method accepting
13   * MuleEventContext.
14   */
15  public class Kiwi implements Fruit
16  {
17      /**
18       * Serial version
19       */
20      private static final long serialVersionUID = -1468423665948468954L;
21  
22      private boolean bitten;
23  
24      public void handle(MuleEventContext eventContext) throws Exception
25      {
26          final Object payload = eventContext.getMessage().getPayload();
27          if (payload instanceof FruitLover)
28          {
29              this.bite();
30          }
31      }
32  
33      public void bite()
34      {
35          this.bitten = true;
36      }
37  
38      public boolean isBitten()
39      {
40          return this.bitten;
41      }
42  
43      @Override
44      public boolean equals(Object o)
45      {
46          if (this == o)
47          {
48              return true;
49          }
50          if (!(o instanceof Kiwi))
51          {
52              return false;
53          }
54  
55          Kiwi kiwi = (Kiwi) o;
56  
57          if (bitten != kiwi.bitten)
58          {
59              return false;
60          }
61  
62          return true;
63      }
64  
65      @Override
66      public int hashCode()
67      {
68          return (bitten ? 1 : 0);
69      }
70  }