View Javadoc

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