View Javadoc

1   package net.sourceforge.basher.events;
2   
3   import java.util.EventObject;
4   
5   /**
6    * @author Johan Lindquist
7    * @version $Revision$
8    */
9   public abstract class BasherEvent extends EventObject
10  {
11      private long _creationTime;
12  
13      public BasherEvent()
14      {
15          super("<none>");
16          _creationTime = System.currentTimeMillis();
17      }
18  
19      /** Retrieves the creation time of this event instance.
20       *
21       * @return  The creation time
22       */
23      public long getCreationTime()
24      {
25          return _creationTime;
26      }
27  
28      /** Sets the creation time of this event instance.
29       *
30       * @param creationTime The creation time to set
31       */
32      void setCreationTime( final long creationTime )
33      {
34          _creationTime = creationTime;
35      }
36  
37      /**
38       * Constructs a prototypical Event.
39       *
40       * @param source The object on which the Event initially occurred.
41       * @throws IllegalArgumentException if source is null.
42       */
43      public BasherEvent(Object source)
44      {
45          super(source);
46          _creationTime = System.currentTimeMillis();
47      }
48  
49  
50  
51      @Override
52      public String toString()
53      {
54          return "BasherEvent{" +
55                  "_creationTime=" + _creationTime +
56                  '}';
57      }
58  
59      @Override
60      public boolean equals( final Object o )
61      {
62          if ( this == o )
63          {
64              return true;
65          }
66          if ( o == null || getClass() != o.getClass() )
67          {
68              return false;
69          }
70  
71          final BasherEvent that = ( BasherEvent ) o;
72  
73          if ( _creationTime != that._creationTime )
74          {
75              return false;
76          }
77  
78          return true;
79      }
80  
81      @Override
82      public int hashCode()
83      {
84          return ( int ) ( _creationTime ^ ( _creationTime >>> 32 ) );
85      }
86  }