TypedRange implements Comparable<TypedRange<T>> { @Override public int compareTo(TypedRange<T> other) { if (getOffset() < other.getOffset()) { return -1; } else if (getOffset() > other.getOffset()) { return 1; } return 0; } TypedRange(long offset, long length, T metadata); @Override String toString(); long getOffset(); long getLength(); T getMetadata(); @Override int hashCode(); @Override boolean equals(Object obj); @Override int compareTo(TypedRange<T> other);  }
@Test public void testCompare() { TypedRange<String> range1 = new TypedRange<String>(1, 777, null); TypedRange<String> range2 = new TypedRange<String>(2, 777, null); Assert.assertTrue(range1.compareTo(range2) < 0); Assert.assertTrue(range2.compareTo(range1) > 0); Assert.assertTrue(range1.compareTo(range1) == 0); }