1   package uk.ac.ebi.intenz.domain.constants;
2   
3   
4   
5   
6   
7   
8   
9   
10  
11  
12  
13  public class EnzymeSourceConstant {
14    private final String sourceCode;
15  
16    public static final EnzymeSourceConstant UNDEF = new EnzymeSourceConstant("UNDEF");
17    public static final EnzymeSourceConstant IUBMB = new EnzymeSourceConstant("IUBMB");
18    public static final EnzymeSourceConstant SIB = new EnzymeSourceConstant("SIB");
19    public static final EnzymeSourceConstant BRENDA = new EnzymeSourceConstant("BRENDA");
20    public static final EnzymeSourceConstant INTENZ = new EnzymeSourceConstant("INTENZ");
21  
22    
23  
24  
25  
26  
27    private EnzymeSourceConstant(String sourceCode) {
28      this.sourceCode = sourceCode;
29    }
30  
31    
32  
33  
34  
35  
36  
37  
38  
39  
40  
41    public static EnzymeSourceConstant valueOf(String sourceCode) {
42      if (sourceCode == null) throw new NullPointerException("Parameter 'sourceCode' must not be null.");
43      if (sourceCode.equals(IUBMB.toString())) return IUBMB;
44      if (sourceCode.equals(SIB.toString())) return SIB;
45      if (sourceCode.equals(BRENDA.toString())) return BRENDA;
46      if (sourceCode.equals(INTENZ.toString())) return INTENZ;
47  	throw new IllegalArgumentException("The given source code is not supported.");
48    }
49  
50    
51  
52  
53  
54  
55  
56    public boolean equals(Object o) {
57      if (this == o) return true;
58      if (!(o instanceof EnzymeSourceConstant)) return false;
59  
60      final EnzymeSourceConstant enzymeSource = (EnzymeSourceConstant) o;
61  
62      if (!sourceCode.equals(enzymeSource.sourceCode)) return false;
63  
64      return true;
65    }
66  
67    
68  
69  
70  
71  
72    public int hashCode() {
73      return sourceCode.hashCode();
74    }
75  
76    
77  
78  
79  
80  
81    public String toString() {
82      return sourceCode;
83    }
84  
85    
86  
87  
88  
89  
90    public static String toDisplayString(String source) {
91      EnzymeSourceConstant sourceConstant = EnzymeSourceConstant.valueOf(source);
92      if(sourceConstant == UNDEF) return "undefined";
93      if(sourceConstant == IUBMB) return "NC-IUBMB";
94      if(sourceConstant == SIB) return "ENZYME";
95      if(sourceConstant == INTENZ) return "IntEnz";
96      return "BRENDA";
97    }
98  
99    
100 
101 
102 
103   public String toDisplayString() {
104     if(this == UNDEF) return "undefined";
105     if(this == IUBMB) return "NC-IUBMB";
106     if(this == SIB) return "ENZYME";
107     if(this == INTENZ) return "IntEnz";
108     return "BRENDA";
109   }
110 }
111 
112