1 package uk.ac.ebi.intenz.domain.constants;
2
3
4
5
6
7
8
9
10
11
12
13 public class EnzymeStatusConstant {
14 private final String statusCode;
15
16 private final String text;
17
18 public static final EnzymeStatusConstant APPROVED = new EnzymeStatusConstant("OK", "approved");
19 public static final EnzymeStatusConstant SUGGESTED = new EnzymeStatusConstant("SU", "suggested");
20 public static final EnzymeStatusConstant PROPOSED = new EnzymeStatusConstant("PR", "proposed");
21
22
23
24
25
26
27
28
29
30
31
32 public static EnzymeStatusConstant valueOf(String statusCode) {
33 if (statusCode == null) throw new NullPointerException("Parameter 'statusCode' must not be null.");
34 if (statusCode.equals(APPROVED.getCode())) return APPROVED;
35 if (statusCode.equals(SUGGESTED.getCode())) return SUGGESTED;
36 if (statusCode.equals(PROPOSED.getCode())) return PROPOSED;
37 throw new IllegalArgumentException("Parameter 'statusCode' is invalid.");
38 }
39
40
41
42
43
44
45 private EnzymeStatusConstant(String statusCode, String text) {
46 this.statusCode = statusCode;
47 this.text = text;
48 }
49
50
51
52
53
54
55
56 public boolean equals(Object o) {
57 if (this == o) return true;
58 if (!(o instanceof EnzymeStatusConstant)) return false;
59
60 final EnzymeStatusConstant enzymeStatus = (EnzymeStatusConstant) o;
61
62 if (statusCode != null ? !statusCode.equals(enzymeStatus.statusCode) : enzymeStatus.statusCode != null) return false;
63 if (text != null ? !text.equals(enzymeStatus.text) : enzymeStatus.text != null) return false;
64
65 return true;
66 }
67
68
69
70
71
72
73 public int hashCode() {
74 int result;
75 result = (statusCode != null ? statusCode.hashCode() : 0);
76 result = 29 * result + (text != null ? text.hashCode() : 0);
77 return result;
78 }
79
80
81
82
83
84
85 public String toString() {
86 return text;
87 }
88
89
90
91
92
93
94 public String getCode() {
95 return statusCode;
96 }
97 }
98
99