View Javadoc

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