View Javadoc
1   package org.esigate.events;
2   
3   /**
4    * Defines an event, with id and type.
5    * 
6    * @author Nicolas Richeton
7    */
8   public class EventDefinition {
9   
10      /**
11       * Standard event type.
12       */
13      public static final int TYPE_DEFAULT = 1;
14      /**
15       * Events which are fired after the main event occurs. These events are identified separately because we need to
16       * execute listeners in a reverse order.
17       */
18      public static final int TYPE_POST = 2;
19  
20      private String id;
21      private int type;
22  
23      /**
24       * Create event defintion.
25       * 
26       * @param id
27       *            Unique identifier for event
28       * @param type
29       *            {@link #TYPE_DEFAULT} or {@link #TYPE_POST}
30       */
31      public EventDefinition(String id, int type) {
32          this.id = id;
33          this.type = type;
34      }
35  
36      public String getId() {
37          return id;
38      }
39  
40      public int getType() {
41          return type;
42      }
43  
44      @Override
45      public String toString() {
46  
47          String strType = Integer.toString(type);
48  
49          if (type == TYPE_POST) {
50              strType = "Post";
51          } else if (type == TYPE_DEFAULT) {
52              strType = "Default";
53          }
54  
55          return id + " (" + strType + ")";
56      }
57  
58  }