1   
2   
3   
4   
5   
6   
7   
8   
9   
10  
11  
12  package ca.spaz.cron.datasource;
13  
14  
15  /***
16   * An event to be fired when a datasource has certain events occur.  This is a
17   * typesafe enumeration pattern.
18   *  
19   * @author Chris Rose
20   */
21  public final class FoodDataEvent {
22  
23     /*** Enumeration number */
24     private final int index;
25  
26     /*** Enumeration name */
27     private final transient String enumName;
28  
29     /*** Enumeration values */
30     
31     public static final FoodDataEvent DSEVENT_FOOD_ADDED = new FoodDataEvent("Food Added", 0);
32  
33     public static final FoodDataEvent DSEVENT_FOOD_DELETED = new FoodDataEvent("Food Deleted", 1);
34  
35     public static final FoodDataEvent DSEVENT_FOOD_CHANGED = new FoodDataEvent("Food Changed", 2);
36  
37     public static final FoodDataEvent DSEVENT_MEASURE_ADDED = new FoodDataEvent("Measure Added", 3);
38  
39     public static final FoodDataEvent DSEVENT_MEASURE_REMOVED = new FoodDataEvent("Measure Removed", 4);
40  
41     public static final FoodDataEvent DSEVENT_MEASURE_CHANGED = new FoodDataEvent("Measures Changed", 5);
42  
43     public static final FoodDataEvent DSEVENT_SERVING_ADDED = new FoodDataEvent("Serving Added", 6);
44  
45     public static final FoodDataEvent DSEVENT_SERVING_REMOVED = new FoodDataEvent("Serving Removed", 7);
46  
47     public static final FoodDataEvent DSEVENT_SERVING_CHANGED = new FoodDataEvent("Serving Changed", 8);
48  
49     /***
50      * Constructor of the enumeration object. <br>
51      *
52      * This constructor should remain private.
53      * 
54      * @param aName the name of the enumeration
55      */
56     private FoodDataEvent(String name, int index) {
57        this.enumName = name;
58        this.index = index;
59     }
60  
61     /***
62      * Returns the enumeration name.
63      *
64      * @return the enumeration name.
65      */
66     public String toString() {
67        return this.enumName;
68     }
69     
70     public int getIndex() {
71        return this.index;
72     }
73  
74  }