01: package web.examples;
02:
03: /**
04: * This enum type is used by {@link EmploymentStatusDataType} as an example
05: * of implementing a custom InputDataType.
06: */
07: public enum EmploymentStatus {
08: EMPLOYED(1, "Employed"), SELF_EMPLOYED(2, "Self-employed"), UNEMPLOYED(
09: 3, "Unemplyed"), RETIRED(4, "Retired"), STUDENT(5,
10: "Student");
11:
12: private int id;
13: private String desc;
14:
15: EmploymentStatus(int id, String desc) {
16: this .id = id;
17: this .desc = desc;
18: }
19:
20: public int getId() {
21: return id;
22: }
23:
24: public String getDesc() {
25: return desc;
26: }
27:
28: public static EmploymentStatus getByID(int id) {
29: for (EmploymentStatus status : values())
30: if (status.getId() == id)
31: return status;
32:
33: throw new IllegalArgumentException("Invalid id: " + id);
34: }
35:
36: }
|