ShapeFileIndexRecord implements Comparable<ShapeFileIndexRecord> { @Override @Pure public int compareTo(ShapeFileIndexRecord record) { if (record == null) { return -1; } final int cmp = this.offset - record.offset; if (cmp != 0) { return cmp; } return this.length - record.length; } ShapeFileIndexRecord(int recordOffset, int length, boolean recordContentSize, int index); @Override @Pure int hashCode(); @Override @Pure boolean equals(Object obj); @Override @Pure int compareTo(ShapeFileIndexRecord record); @Override @Pure String toString(); @Pure int getOffsetInFile(); @Pure int getOffsetInContent(); @Pure int getEntireRecordLength(); @Pure int getRecordContentLength(); @Pure int getRecordIndex();  }
@Test public void testCompareTo() { assertStrictlyNegative(this.record.compareTo(null)); assertZero(this.record.compareTo(this.record)); assertZero(this.record.compareTo(new ShapeFileIndexRecord(this.offset, this.length, false, -1))); assertStrictlyNegative(this.record.compareTo(new ShapeFileIndexRecord(this.offset, this.length+2, false, -1))); assertStrictlyPositive(this.record.compareTo(new ShapeFileIndexRecord(this.offset, this.length-2, false, -1))); assertStrictlyNegative(this.record.compareTo(new ShapeFileIndexRecord(this.offset+2, this.length, false, -1))); assertStrictlyNegative(this.record.compareTo(new ShapeFileIndexRecord(this.offset+2, this.length+2, false, -1))); assertStrictlyNegative(this.record.compareTo(new ShapeFileIndexRecord(this.offset+2, this.length-2, false, -1))); assertStrictlyPositive(this.record.compareTo(new ShapeFileIndexRecord(this.offset-2, this.length, false, -1))); assertStrictlyPositive(this.record.compareTo(new ShapeFileIndexRecord(this.offset-2, this.length+2, false, -1))); assertStrictlyPositive(this.record.compareTo(new ShapeFileIndexRecord(this.offset-2, this.length-2, false, -1))); }