Range implements Comparable<Range> { @Override public int compareTo(Range comparedRange) { if (start != comparedRange.start) { return start > comparedRange.start ? 1 : -1; } else { return end > comparedRange.end ? 1 : ((end == comparedRange.end) ? 0 : -1); } } Range(long startOffset, long endOffset);  Range(); boolean contains(long someOffset); static boolean containsReaderPosition(long writerStart,
												long writerEnd,
												long readerPosition,
												BufferPositionParser parser); static boolean containsIgnoreGenId(long start,
			                                  long end,
			                                  long offset,
			                                  BufferPositionParser parser); static boolean contains(long start, long end, long someOffset); boolean intersects(Range intersectedRange); @Override int compareTo(Range comparedRange); String toString(BufferPositionParser parser); @Override String toString(); long getStart(); void setStart(long start); long getEnd(); void setEnd(long end); @Override boolean equals(Object obj); @Override int hashCode(); public long start; public long end; }
@Test public void testCompareTo() { { Range r1 = new Range(1, 100); Range r2 = new Range(2, 100); AssertJUnit.assertTrue(r1.compareTo(r2) < 0); } { Range r1 = new Range(0x100000000L, 0x10000050L); Range r2 = new Range(2, 100); AssertJUnit.assertTrue(r1.compareTo(r2) > 0); } { Range r1 = new Range(1, 100); AssertJUnit.assertTrue(r1.compareTo(r1) == 0); } }