1 package uk.ac.ebi.intenz.domain.enzyme;
2
3 import java.util.List;
4
5
6
7
8
9
10
11
12
13 public class EnzymeClass implements Comparable<EnzymeClass> {
14
15 private EnzymeCommissionNumber ec;
16
17 private String name;
18
19 private String description;
20
21 private List<EnzymeSubclass> subclasses;
22
23
24
25
26
27
28
29
30
31 private EnzymeClass(EnzymeCommissionNumber ec, String name, String description, List<EnzymeSubclass> subclasses) {
32 this.ec = ec;
33 this.name = name;
34 this.description = description;
35 this.subclasses = subclasses;
36 }
37
38
39
40
41
42
43
44
45
46
47
48 public static EnzymeClass valueOf(EnzymeCommissionNumber ec, String name, String description,
49 List<EnzymeSubclass> subclasses) {
50 if (ec == null || name == null || description == null || subclasses == null)
51 throw new NullPointerException("No parameter must be 'null'.");
52 if (name.equals("")) throw new IllegalArgumentException("A class must have a name.");
53 if (subclasses.size() == 0) throw new IllegalArgumentException("The list of subclasses must not be empty.");
54 return new EnzymeClass(ec, name, description, subclasses);
55 }
56
57
58
59
60
61
62
63 public int compareTo(EnzymeClass enzymeClass) {
64 return ec.compareTo(enzymeClass.getEc());
65 }
66
67
68
69
70
71
72
73 public boolean equals(Object o) {
74 if (this == o) return true;
75 if (!(o instanceof EnzymeClass)) return false;
76
77 final EnzymeClass enzymeClass = (EnzymeClass) o;
78
79 if (description != null ? !description.equals(enzymeClass.description) : enzymeClass.description != null) return false;
80 if (ec != null ? !ec.equals(enzymeClass.ec) : enzymeClass.ec != null) return false;
81 if (name != null ? !name.equals(enzymeClass.name) : enzymeClass.name != null) return false;
82 if (subclasses != null ? !subclasses.equals(enzymeClass.subclasses) : enzymeClass.subclasses != null) return false;
83
84 return true;
85 }
86
87 public int hashCode() {
88 int result;
89 result = (ec != null ? ec.hashCode() : 0);
90 result = 29 * result + (name != null ? name.hashCode() : 0);
91 result = 29 * result + (description != null ? description.hashCode() : 0);
92 result = 29 * result + (subclasses != null ? subclasses.hashCode() : 0);
93 return result;
94 }
95
96
97
98
99
100
101
102
103
104
105
106 public EnzymeCommissionNumber getEc() {
107 return ec;
108 }
109
110 public String getName() {
111 return name;
112 }
113
114 public String getDescription() {
115 return description;
116 }
117
118 public List<EnzymeSubclass> getSubclasses() {
119 return subclasses;
120 }
121
122 }