1
2
3
4 package net.sf.tomp.general;
5
6 /***
7 * @author tomp
8 */
9 public class Identifiable {
10 private String id;
11
12 /*** Creates a new instance of Identifiable */
13 public Identifiable(String i) {
14 if ((i == null) || (i.length() == 0)) {
15 throw new IllegalArgumentException("Cannot create "
16 + getClass().getName() + " with id=null or empty");
17 }
18
19 id = i;
20 }
21
22 public String getId() {
23 return id;
24 }
25
26 public void setId(String s) {
27 id = s;
28 }
29
30 public int hashCode() {
31 return id.hashCode();
32 }
33
34 public boolean equals(Object o) {
35 if (o instanceof Identifiable) {
36 Identifiable ui = (Identifiable) o;
37
38 return id.equals(ui.getId());
39 } else {
40 return false;
41 }
42 }
43 }