-
-
Notifications
You must be signed in to change notification settings - Fork 103
Expand file tree
/
Copy pathPosition.java
More file actions
45 lines (36 loc) · 810 Bytes
/
Position.java
File metadata and controls
45 lines (36 loc) · 810 Bytes
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
package org.herb;
public class Position {
private final int line;
private final int column;
public Position(int line, int column) {
this.line = line;
this.column = column;
}
public int getLine() {
return line;
}
public int getColumn() {
return column;
}
@Override
public String toString() {
return inspect();
}
public String inspect() {
return String.format("(%d:%d)", line, column);
}
public String treeInspect() {
return inspect();
}
@Override
public boolean equals(Object obj) {
if (this == obj) return true;
if (!(obj instanceof Position)) return false;
Position other = (Position) obj;
return line == other.line && column == other.column;
}
@Override
public int hashCode() {
return 31 * line + column;
}
}