1 |
duarte |
184 |
package proteinstructure; |
2 |
|
|
import java.lang.Comparable; |
3 |
|
|
|
4 |
|
|
public class GenericContact implements Comparable { |
5 |
|
|
|
6 |
|
|
public String i_res; |
7 |
|
|
public String j_res; |
8 |
|
|
|
9 |
|
|
public GenericContact(String i_res,String j_res){ |
10 |
|
|
this.i_res=i_res; |
11 |
|
|
this.j_res=j_res; |
12 |
|
|
} |
13 |
|
|
|
14 |
|
|
public int compareTo(Object o) { |
15 |
|
|
int diff=0; |
16 |
|
|
GenericContact other = (GenericContact) o; |
17 |
|
|
if (this.i_res.compareTo(other.i_res)>0){ |
18 |
|
|
diff=1; |
19 |
|
|
} |
20 |
|
|
else if (this.i_res.compareTo(other.i_res)<0){ |
21 |
|
|
diff=-1; |
22 |
|
|
} |
23 |
|
|
else if (this.i_res.equals(other.i_res)){ |
24 |
|
|
if (this.j_res.compareTo(other.j_res)>0){ |
25 |
|
|
diff=1; |
26 |
|
|
} |
27 |
|
|
else if (this.j_res.compareTo(other.j_res)<0){ |
28 |
|
|
diff=-1; |
29 |
|
|
} |
30 |
|
|
} |
31 |
|
|
return diff; |
32 |
|
|
} |
33 |
|
|
|
34 |
|
|
public boolean equals(Object o){ |
35 |
|
|
boolean eq = false; |
36 |
|
|
GenericContact other = (GenericContact) o; |
37 |
duarte |
185 |
if (this.i_res.equals(other.i_res) && this.j_res.equals(other.j_res)){ |
38 |
duarte |
184 |
eq=true; |
39 |
|
|
} |
40 |
|
|
return eq; |
41 |
|
|
} |
42 |
|
|
|
43 |
|
|
public String toString() { |
44 |
duarte |
185 |
return this.i_res+" "+this.j_res; |
45 |
duarte |
184 |
} |
46 |
duarte |
185 |
|
47 |
|
|
public int hashCode() { |
48 |
|
|
return this.toString().hashCode(); |
49 |
|
|
} |
50 |
|
|
|
51 |
duarte |
184 |
} |