View Javadoc

1   package uk.ac.ebi.intenz.domain.enzyme;
2   
3   import java.util.List;
4   
5   /**
6    * This class represents an enzyme sub-subclass of the Enzyme Nomenclature.
7    * <p/>
8    * Instances of this class are immutable.
9    *
10   * @author Michael Darsow
11   * @version $Revision: 1.2 $ $Date: 2008/01/28 12:33:00 $
12   */
13  public class EnzymeSubSubclass {
14    private EnzymeCommissionNumber ec;
15  
16    private String className;
17  
18    private String subclassName;
19  
20    private String name;
21  
22    private String description;
23  
24    private List<EnzymeEntry> entries;
25  
26    /**
27     * Returns an <code>EnzymeSubSubclass</code> instance.
28     *
29     * @param ec           The class' EC.
30     * @param className    The name of the class.
31     * @param subclassName The name of the subclass.
32     * @param name         The name of the subclass.
33     * @param description  The description of the class.
34     * @param entries      The list of entries (see {@link EnzymeEntry}).
35     * @throws NullPointerException     if any parameters are <code>null</code> apart from <code>name</code> and <code>description</code>.
36     * @throws IllegalArgumentException if the list of entries is empty.
37     */
38    public EnzymeSubSubclass(EnzymeCommissionNumber ec, String className, String subclassName, String name,
39                             String description, List<EnzymeEntry> entries) {
40      if (ec == null || className == null || subclassName == null)
41        throw new NullPointerException("No parameter must be 'null'.");
42      this.ec = ec;
43      this.className = className;
44      this.subclassName = subclassName;
45      this.name = name != null ? name : "";
46      this.description = description != null ? description : "";
47      this.entries = entries;
48    }
49  
50    /**
51     * Makes instances of this class comparable.
52     *
53     * @param o The object to be compared to this instance.
54     * @return a pos. integer if this instance is greater than, a neg. integer if it is less than or 0 if it equals o.
55     * @throws NullPointerException if <code>o</code> is <code>null</code>.
56     */
57    public int compareTo(Object o) {
58      if (o == null) throw new NullPointerException("Parameter 'o' must not be null.");
59      EnzymeSubSubclass enzymeSubSubclass = (EnzymeSubSubclass) o;
60      return ec.compareTo(enzymeSubSubclass.getEc());
61    }
62  
63    /**
64     * Standard equals method.
65     *
66     * @param o Object to be compared to this one.
67     * @return <code>true</code> if the objects are equal.
68     */
69    public boolean equals(Object o) {
70      if (this == o) return true;
71      if (!(o instanceof EnzymeSubSubclass)) return false;
72  
73      final EnzymeSubSubclass enzymeSubSubclass = (EnzymeSubSubclass) o;
74  
75      if (className != null ? !className.equals(enzymeSubSubclass.className) : enzymeSubSubclass.className != null) return false;
76      if (description != null ? !description.equals(enzymeSubSubclass.description) : enzymeSubSubclass.description != null) return false;
77      if (ec != null ? !ec.equals(enzymeSubSubclass.ec) : enzymeSubSubclass.ec != null) return false;
78      if (entries != null ? !entries.equals(enzymeSubSubclass.entries) : enzymeSubSubclass.entries != null) return false;
79      if (name != null ? !name.equals(enzymeSubSubclass.name) : enzymeSubSubclass.name != null) return false;
80      if (subclassName != null ? !subclassName.equals(enzymeSubSubclass.subclassName) : enzymeSubSubclass.subclassName != null) return false;
81  
82      return true;
83    }
84  
85    /**
86     * Returns the hash code of this object.
87     *
88     * @return the hash code of this object.
89     */
90    public int hashCode() {
91      int result;
92      result = (ec != null ? ec.hashCode() : 0);
93      result = 29 * result + (className != null ? className.hashCode() : 0);
94      result = 29 * result + (subclassName != null ? subclassName.hashCode() : 0);
95      result = 29 * result + (name != null ? name.hashCode() : 0);
96      result = 29 * result + (description != null ? description.hashCode() : 0);
97      result = 29 * result + (entries != null ? entries.hashCode() : 0);
98      return result;
99    }
100 
101 
102   // ----------------  GETTER ------------------
103 
104   public EnzymeCommissionNumber getEc() {
105     return ec;
106   }
107 
108   public String getClassName() {
109     return className;
110   }
111 
112   public String getSubclassName() {
113     return subclassName;
114   }
115 
116   public String getName() {
117     return name;
118   }
119 
120   public String getDescription() {
121     return description;
122   }
123 
124   public List<EnzymeEntry> getEntries() {
125     return entries;
126   }
127 }