View Javadoc

1   package net.sourceforge.basher.impl;
2   
3   import net.sourceforge.basher.events.BasherEvent;
4   import net.sourceforge.basher.events.EventManager;
5   
6   /**
7    * @author Johan Lindquist
8    * @version $Revision$
9    */
10  public class EventEmitterTimerTask implements Runnable
11  {
12      private final EventManager _eventManager;
13      private final BasherEvent _basherEvent;
14  
15      public EventEmitterTimerTask(final EventManager eventManager, final BasherEvent basherEvent)
16      {
17          _eventManager = eventManager;
18          _basherEvent = basherEvent;
19      }
20  
21      public BasherEvent getBasherEvent()
22      {
23          return _basherEvent;
24      }
25  
26      public void run()
27      {
28          _eventManager.publish(_basherEvent);
29      }
30  
31      @Override
32      public String toString()
33      {
34          return "EventEmitterTimerTask{" +
35                  "_eventManager=" + _eventManager +
36                  ", _basherEvent=" + _basherEvent +
37                  '}';
38      }
39  
40      @Override
41      public boolean equals( final Object o )
42      {
43          if ( this == o )
44          {
45              return true;
46          }
47          if ( o == null || getClass() != o.getClass() )
48          {
49              return false;
50          }
51  
52          final EventEmitterTimerTask that = ( EventEmitterTimerTask ) o;
53  
54          if ( _basherEvent != null ? !_basherEvent.equals( that._basherEvent ) : that._basherEvent != null )
55          {
56              return false;
57          }
58          if ( _eventManager != null ? !_eventManager.equals( that._eventManager ) : that._eventManager != null )
59          {
60              return false;
61          }
62  
63          return true;
64      }
65  
66      @Override
67      public int hashCode()
68      {
69          int result = _eventManager != null ? _eventManager.hashCode() : 0;
70          result = 31 * result + ( _basherEvent != null ? _basherEvent.hashCode() : 0 );
71          return result;
72      }
73  }