1 package info.ejava.examples.ejb.cdisales.bo;
2
3 public enum ProductCategory {
4 ELECTRONICS ("Electronics"),
5 TOOLS ("Tools"),
6 MARINE ("Marine"),
7 SPORT ("Sport");
8
9 private final String prettyName;
10 private ProductCategory(String prettyName) { this.prettyName = prettyName; }
11
12 public String getPrettyName() { return prettyName; }
13 public static ProductCategory fromString(String value) {
14 if (value==null) { return null; }
15
16 ProductCategory pc = ProductCategory.valueOf(value);
17 if (pc!=null) {
18 return pc;
19 } else {
20 for (ProductCategory pc2: values()) {
21 if (pc2.prettyName.equalsIgnoreCase(value)) {
22 return pc2;
23 }
24 }
25 }
26
27 return null;
28 }
29 }