@Test void testCompareToDifferentOffset() { LineOffset offsetOne = new LineOffset(1, 1); LineOffset offsetTwo = new LineOffset(1, 2); assertTrue(offsetOne.compareTo(offsetTwo) < 0); assertTrue(offsetTwo.compareTo(offsetOne) > 0); }
@Override public int compareTo(Object o) { LineOffset that = (LineOffset) o; if (this.lineNum != that.lineNum) { return this.lineNum - that.lineNum; } return this.offset - that.offset; }
LineOffset implements Comparable { @Override public int compareTo(Object o) { LineOffset that = (LineOffset) o; if (this.lineNum != that.lineNum) { return this.lineNum - that.lineNum; } return this.offset - that.offset; } }
LineOffset implements Comparable { @Override public int compareTo(Object o) { LineOffset that = (LineOffset) o; if (this.lineNum != that.lineNum) { return this.lineNum - that.lineNum; } return this.offset - that.offset; } LineOffset(int lineNum, int offset); }
LineOffset implements Comparable { @Override public int compareTo(Object o) { LineOffset that = (LineOffset) o; if (this.lineNum != that.lineNum) { return this.lineNum - that.lineNum; } return this.offset - that.offset; } LineOffset(int lineNum, int offset); @Override String toString(); @Override boolean equals(Object o); @Override int hashCode(); @Override int compareTo(Object o); }
LineOffset implements Comparable { @Override public int compareTo(Object o) { LineOffset that = (LineOffset) o; if (this.lineNum != that.lineNum) { return this.lineNum - that.lineNum; } return this.offset - that.offset; } LineOffset(int lineNum, int offset); @Override String toString(); @Override boolean equals(Object o); @Override int hashCode(); @Override int compareTo(Object o); final int lineNum; final int offset; }