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 java.util.EventObject;
10  
11  import org.apache.commons.logging.Log;
12  import org.apache.commons.logging.LogFactory;
13  
14  public class Banana implements Fruit
15  {
16      /**
17       * Serial version
18       */
19      private static final long serialVersionUID = -1371515374040436874L;
20  
21      /**
22       * logger used by this class
23       */
24      private static final Log logger = LogFactory.getLog(Banana.class);
25  
26      private boolean peeled = false;
27      private boolean bitten = false;
28  
29      public void peel()
30      {
31          peeled = true;
32      }
33  
34      public void peelEvent(EventObject e)
35      {
36          logger.debug("Banana got peel event in peelEvent(EventObject)! MuleEvent says: "
37                          + e.getSource().toString());
38          peel();
39      }
40  
41      public boolean isPeeled()
42      {
43          return peeled;
44      }
45  
46      public void bite()
47      {
48          bitten = true;
49      }
50  
51      public boolean isBitten()
52      {
53          return bitten;
54      }
55  
56      @Override
57      public boolean equals(Object o)
58      {
59          if (this == o)
60          {
61              return true;
62          }
63          if (!(o instanceof Banana))
64          {
65              return false;
66          }
67  
68          Banana banana = (Banana) o;
69  
70          if (bitten != banana.bitten)
71          {
72              return false;
73          }
74          if (peeled != banana.peeled)
75          {
76              return false;
77          }
78  
79          return true;
80      }
81  
82      @Override
83      public int hashCode()
84      {
85          int result = (peeled ? 1 : 0);
86          result = 31 * result + (bitten ? 1 : 0);
87          return result;
88      }
89  }