View Javadoc

1   package net.sourceforge.basher.events;
2   
3   import net.sourceforge.basher.BasherContext;
4   
5   /**
6    * @author Johan Lindquist
7    * @version $Revision$
8    */
9   public class ThreadAddedEvent extends BasherEvent
10  {
11      private String _name;
12      private int _currentNumberThreads;
13      private final BasherContext _basherContext;
14  
15      /**
16       * @param name
17       * @param currentNumberThreads
18       * @param basherContext
19       */
20      public ThreadAddedEvent(final String name, final int currentNumberThreads, final BasherContext basherContext)
21      {
22          _name = name;
23          _currentNumberThreads = currentNumberThreads;
24          _basherContext = basherContext;
25      }
26  
27      /** Returns the name of the thread to stop
28       *
29       * @return The name of the thread which should be stopped.
30       */
31      public String getName()
32      {
33          return _name;
34      }
35  
36      /** Retrieves the current number of threads running after the new thread was added
37       *
38       * @return The number of threads now running
39       */
40      public int getCurrentNumberThreads()
41      {
42          return _currentNumberThreads;
43      }
44  
45      /** Retrives the <code>BasherContext</code> currently running.
46       *
47       * @return  The current Basher context
48       */
49      public BasherContext getBasherContext()
50      {
51          return _basherContext;
52      }
53  
54      @Override
55      public String toString()
56      {
57          return "ThreadAddedEvent{" +
58                  "_name='" + _name + '\'' +
59                  ", _currentNumberThreads=" + _currentNumberThreads +
60                  ", _basherContext=" + _basherContext +
61                  "} " + super.toString();
62      }
63  
64      @Override
65      public boolean equals(final Object o)
66      {
67          if (this == o)
68          {
69              return true;
70          }
71          if (o == null || getClass() != o.getClass())
72          {
73              return false;
74          }
75          if (!super.equals(o))
76          {
77              return false;
78          }
79  
80          final ThreadAddedEvent that = (ThreadAddedEvent) o;
81  
82          if (_currentNumberThreads != that._currentNumberThreads)
83          {
84              return false;
85          }
86          if (_basherContext != null ? !_basherContext.equals(that._basherContext) : that._basherContext != null)
87          {
88              return false;
89          }
90          if (_name != null ? !_name.equals(that._name) : that._name != null)
91          {
92              return false;
93          }
94  
95          return true;
96      }
97  
98      @Override
99      public int hashCode()
100     {
101         int result = super.hashCode();
102         result = 31 * result + (_name != null ? _name.hashCode() : 0);
103         result = 31 * result + _currentNumberThreads;
104         result = 31 * result + (_basherContext != null ? _basherContext.hashCode() : 0);
105         return result;
106     }
107 }