1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.promotego.beans;
20
21 import java.util.HashSet;
22 import java.util.Set;
23
24 import javax.persistence.Entity;
25
26 @Entity
27 public class LocationType extends BeanSupport<LocationType> implements Comparable<LocationType>
28 {
29 private String m_name;
30 private int m_ordinal;
31
32 /***
33 * Locations to initialize in the database, if none are already present.
34 * Ordinals will be assigned based on the order given here.
35 */
36 private static final String [] s_initialLocations = {
37 "Coffee House", "Library", "Park", "Bookstore", "Go Club", "Other"
38 };
39
40 public static Set<LocationType> getInitialLocations()
41 {
42 Set<LocationType> retval = new HashSet<LocationType>();
43
44 int ordinal = 0;
45 for (String name : s_initialLocations)
46 {
47 LocationType thisType = new LocationType();
48 thisType.setName(name);
49 thisType.setOrdinal(ordinal);
50
51 ordinal++;
52
53 retval.add(thisType);
54 }
55
56 return retval;
57 }
58
59 public String getName()
60 {
61 return m_name;
62 }
63
64 public void setName(String name)
65 {
66 m_name = name;
67 }
68
69 public int getOrdinal()
70 {
71 return m_ordinal;
72 }
73
74 public void setOrdinal(int ordinal)
75 {
76 m_ordinal = ordinal;
77 }
78
79 public int compareTo(LocationType o)
80 {
81 return getOrdinal() - o.getOrdinal();
82 }
83 }