-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathField.java
More file actions
51 lines (42 loc) · 1.09 KB
/
Copy pathField.java
File metadata and controls
51 lines (42 loc) · 1.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
package data;
public class Field implements Addr{
private Location loc;
private String str;
public Field(Location l, String s){
loc = l;
str = s;
}
public Location getLoc(){
return loc;
}
public String getString(){
return str;
}
public int hashCode(){
final int PRIME = 31;
int result = 1;
result = PRIME * result + ( (loc == null) ? 0 : loc.hashCode());
result = PRIME * result + ( (str == null) ? 0 : str.hashCode());
return result;
}
public boolean equals(Object o){
if (this == o ) return true;
if (o == null) return false;
if (getClass() != o.getClass()) return false;
Field f = (Field) o;
if (!loc.equals(f.getLoc())) return false;
return str.equals(f.getString());
}
public String toString(){
return "(" + loc.toString() + "," + str + ")";
}
@Override
public int compareTo(Addr o) {
int classCompare = getClass().getName().compareTo(o.getClass().getName());
if (classCompare != 0) return classCompare;
Field f = (Field) o;
int ret = loc.compareTo(f.getLoc());
if (ret != 0) return ret;
return str.compareTo(f.getString());
}
}