View Javadoc

1   /*
2    *******************************************************************************
3    * Copyright (c) 2005 Chris Rose and AIMedia
4    * All rights reserved. FoodDataEvent and the accompanying materials
5    * are made available under the terms of the Common Public License v1.0
6    * which accompanies this distribution, and is available at
7    * http://www.eclipse.org/legal/cpl-v10.html
8    * 
9    * Contributors:
10   *     Chris Rose
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     // manual code: replace "ENUMERATION_VALUE_<i>" by the real enumeration identifiers  
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  }