TableRange implements Comparable<TableRange> { @Override public int compareTo(TableRange other) { return TABLE_RANGE_COMPARATOR.compare(this, other); } TableRange(Bytes per, Bytes er); @Override int hashCode(); @Override boolean equals(Object o); Bytes getPrevEndRow(); Bytes getEndRow(); boolean contains(Bytes row); @Override String toString(); static List<TableRange> fromBytes(Collection<Bytes> rows); static List<TableRange> fromTexts(Collection<Text> rows); Range getRange(); @Override int compareTo(TableRange other);  }
@Test public void testCompare() { Bytes sp1 = Bytes.of("e1"); Bytes sp2 = Bytes.of("m1"); TableRange tr1 = new TableRange(null, sp1); TableRange tr2 = new TableRange(sp1, sp2); TableRange tr3 = new TableRange(sp2, null); Assert.assertTrue(tr1.compareTo(tr2) < 0); Assert.assertTrue(tr2.compareTo(tr1) > 0); Assert.assertTrue(tr2.compareTo(tr3) < 0); Assert.assertTrue(tr3.compareTo(tr2) > 0); Assert.assertTrue(tr1.compareTo(tr3) < 0); Assert.assertTrue(tr3.compareTo(tr1) > 0); Assert.assertEquals(0, tr1.compareTo(tr1)); Assert.assertEquals(0, tr2.compareTo(tr2)); Assert.assertEquals(0, tr3.compareTo(tr3)); Assert.assertEquals(0, tr1.compareTo(new TableRange(null, sp1))); Assert.assertEquals(0, tr2.compareTo(new TableRange(sp1, sp2))); Assert.assertEquals(0, tr3.compareTo(new TableRange(sp2, null))); Assert.assertEquals(0, new TableRange(null, null).compareTo(new TableRange(null, null))); }