Skip to content
Snippets Groups Projects
Commit 6c4b3121 authored by dgelessus's avatar dgelessus
Browse files

Implement missing equals/hashCode for SourcePosition

parent d2eaf66b
No related branches found
No related tags found
No related merge requests found
Pipeline #87662 passed
......@@ -6,6 +6,8 @@
package de.hhu.stups.sablecc.patch;
import java.util.Objects;
public class SourcePosition implements Comparable<SourcePosition> {
private final int line;
......@@ -25,6 +27,23 @@ public class SourcePosition implements Comparable<SourcePosition> {
return pos;
}
@Override
public boolean equals(final Object obj) {
if (this == obj) {
return true;
}
if (obj == null || this.getClass() != obj.getClass()) {
return false;
}
final SourcePosition other = (SourcePosition)obj;
return this.getLine() == other.getLine() && this.getPos() == other.getPos();
}
@Override
public int hashCode() {
return Objects.hash(this.getLine(), this.getPos());
}
@Override
public int compareTo(SourcePosition that) {
if (this.line < that.line) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment