1 package uk.ac.ebi.intenz.domain.enzyme;
2
3 import uk.ac.ebi.intenz.domain.constants.EnzymeSourceConstant;
4 import uk.ac.ebi.intenz.domain.constants.EnzymeViewConstant;
5 import uk.ac.ebi.rhea.domain.Compound;
6
7
8
9
10
11
12
13
14
15
16
17
18
19 public class Cofactor implements Viewable {
20
21 public static enum Operators {
22
23 AND("AND", "AND"),
24
25 OR_OPTIONAL("OR", "OR1"),
26
27 OR_FAMILIES("OR", "OR2"),
28
29 OR_UNKNOWN("OR", "OR3");
30 private String text;
31 private String code;
32 private Operators(String t, String c){ this.text = t; this.code = c; }
33 @Override
34 public String toString(){ return text; }
35 public String getCode(){ return code; }
36 public static String[] getCodes(){
37 String[] result = new String[values().length];
38 for (int i = 0; i < result.length; i++) {
39 result[i] = values()[i].getCode();
40 }
41 return result;
42 }
43 }
44
45
46
47
48
49 private String cofactorValue;
50
51 private EnzymeSourceConstant source;
52
53 private EnzymeViewConstant view;
54
55 private Compound compound;
56
57
58
59
60
61
62
63
64
65 public Cofactor(String cofactorValue, EnzymeSourceConstant source, EnzymeViewConstant view) {
66 if (cofactorValue == null) throw new NullPointerException("Parameter 'cofactorValue' must not be null.");
67 if (cofactorValue.equals("")) throw new IllegalArgumentException("Parameter 'cofactorValue' must not be empty.");
68 if (source == null) throw new NullPointerException("Parameter 'source' must not be null.");
69 if (view == null) throw new NullPointerException("Parameter 'view' must not be null.");
70 this.cofactorValue = cofactorValue;
71 this.source = source;
72 this.view = view;
73 }
74
75 private Cofactor(Compound compound, EnzymeSourceConstant source,
76 EnzymeViewConstant view) {
77 this.compound = compound;
78 this.source = source;
79 this.view = view;
80 }
81
82
83
84
85
86
87
88
89 public static Cofactor valueOf(Compound compound, EnzymeSourceConstant source,
90 EnzymeViewConstant view) {
91 if (compound == null)
92 throw new NullPointerException("null compound");
93 if (source == null)
94 throw new NullPointerException("null source");
95 if (view == null)
96 throw new NullPointerException("null view");
97 return new Cofactor(compound, source, view);
98 }
99
100
101
102
103
104
105
106 @Override
107 public boolean equals(Object o) {
108 if (this == o) return true;
109 if (!(o instanceof Cofactor)) return false;
110
111 final Cofactor cofactor = (Cofactor) o;
112
113 if (!compound.equals(cofactor.compound))
114 return false;
115 if (source != null ? !source.equals(cofactor.source) : cofactor.source != null)
116 return false;
117 if (view != null ? !view.equals(cofactor.view) : cofactor.view != null)
118 return false;
119
120 return true;
121 }
122
123
124
125
126
127
128 @Override
129 public int hashCode() {
130 int result;
131 result = (compound != null ? compound.hashCode() : 0);
132 result = 29 * result + (source != null ? source.hashCode() : 0);
133 result = 29 * result + (view != null ? view.hashCode() : 0);
134 return result;
135 }
136
137
138
139
140
141
142
143
144
145
146 public String getCofactorValue() {
147 return cofactorValue;
148 }
149
150 public EnzymeSourceConstant getSource() {
151 return source;
152 }
153
154 public EnzymeViewConstant getView() {
155 return view;
156 }
157
158 public Compound getCompound() {
159 return compound;
160 }
161
162 @Override
163 public String toString() {
164 return compound.toString();
165 }
166
167 }