01: package com.technoetic.xplanner.domain;
02:
03: import java.text.MessageFormat;
04:
05: public class StoryStatus extends CharacterEnum {
06:
07: public static final String DRAFT_NAME = "draft";
08: public static final String DEFINED_NAME = "defined";
09: public static final String ESTIMATED_NAME = "estimated";
10: public static final String PLANNED_NAME = "planned";
11: public static final String IMPLEMENTED_NAME = "implemented";
12: public static final String VERIFIED_NAME = "verified";
13: public static final String ACCEPTED_NAME = "accepted";
14:
15: private static final String NAME_KEY_TEMPLATE = "story.status.{0}.name";
16: private static final String ABBREVIATION_KEY_TEMPLATE = "story.status.{0}.abbreviation";
17:
18: public static final StoryStatus DRAFT = new StoryStatus('d',
19: DRAFT_NAME);
20: public static final StoryStatus DEFINED = new StoryStatus('D',
21: DEFINED_NAME);
22: public static final StoryStatus ESTIMATED = new StoryStatus('e',
23: ESTIMATED_NAME);
24: public static final StoryStatus PLANNED = new StoryStatus('p',
25: PLANNED_NAME);
26: public static final StoryStatus IMPLEMENTED = new StoryStatus('i',
27: IMPLEMENTED_NAME);
28: public static final StoryStatus VERIFIED = new StoryStatus('v',
29: VERIFIED_NAME);
30: public static final StoryStatus ACCEPTED = new StoryStatus('a',
31: ACCEPTED_NAME);
32:
33: private static transient final StoryStatus[] enums = { DRAFT,
34: DEFINED, ESTIMATED, PLANNED, IMPLEMENTED, VERIFIED,
35: ACCEPTED };
36:
37: StoryStatus(char code, String name) {
38: super (code, name);
39: }
40:
41: public String getAbbreviationKey() {
42: return MessageFormat.format(ABBREVIATION_KEY_TEMPLATE,
43: new String[] { name });
44: }
45:
46: // protected StoryStatus(char code, String name) {
47: // this(code, name, name, "" + name.charAt(0));
48: // }
49:
50: public String getNameKey() {
51: return MessageFormat.format(NAME_KEY_TEMPLATE,
52: new String[] { name });
53: }
54:
55: public CharacterEnum[] listEnums() {
56: return enums;
57: }
58:
59: public static StoryStatus valueOf(String key) {
60: return (StoryStatus) valueOf(key, enums);
61: }
62:
63: public static StoryStatus fromNameKey(String key) {
64: return (StoryStatus) fromNameKey(key, enums);
65: }
66:
67: public static StoryStatus fromCode(char code) {
68: return (StoryStatus) fromCode(code, enums);
69: }
70:
71: public static StoryStatus fromName(String name) {
72: return (StoryStatus) fromName(name, enums);
73: }
74:
75: }
|