/** * Compare the region info. * @param other region plan you are comparing against */ @Override public int compareTo(RegionPlan other) { return compareTo(this, other); }
@Test public void testCompareTo() { RegionInfo hri = RegionInfoBuilder.newBuilder(TableName.valueOf(name.getMethodName())).build(); RegionPlan a = new RegionPlan(hri, null, null); RegionPlan b = new RegionPlan(hri, null, null); assertEquals(0, a.compareTo(b)); a = new RegionPlan(hri, SRC, null); b = new RegionPlan(hri, null, null); assertEquals(1, a.compareTo(b)); a = new RegionPlan(hri, null, null); b = new RegionPlan(hri, SRC, null); assertEquals(-1, a.compareTo(b)); a = new RegionPlan(hri, SRC, null); b = new RegionPlan(hri, SRC, null); assertEquals(0, a.compareTo(b)); a = new RegionPlan(hri, SRC, null); b = new RegionPlan(hri, SRC, DEST); assertEquals(-1, a.compareTo(b)); a = new RegionPlan(hri, SRC, DEST); b = new RegionPlan(hri, SRC, DEST); assertEquals(0, a.compareTo(b)); }
@Override public boolean equals(Object obj) { if (this == obj) { return true; } if (obj == null || getClass() != obj.getClass()) { return false; } RegionPlan other = (RegionPlan) obj; return compareTo(other) == 0; }
@Test public void testCompareTo() { RegionInfo hri = RegionInfoBuilder.newBuilder(TableName.valueOf(name.getMethodName())).build(); RegionPlan a = new RegionPlan(hri, null, null); RegionPlan b = new RegionPlan(hri, null, null); assertEquals(0, a.compareTo(b)); a = new RegionPlan(hri, SRC, null); b = new RegionPlan(hri, null, null); assertEquals(1, a.compareTo(b)); a = new RegionPlan(hri, null, null); b = new RegionPlan(hri, SRC, null); assertEquals(-1, a.compareTo(b)); a = new RegionPlan(hri, SRC, null); b = new RegionPlan(hri, SRC, null); assertEquals(0, a.compareTo(b)); a = new RegionPlan(hri, SRC, null); b = new RegionPlan(hri, SRC, DEST); assertEquals(-1, a.compareTo(b)); a = new RegionPlan(hri, SRC, DEST); b = new RegionPlan(hri, SRC, DEST); assertEquals(0, a.compareTo(b)); }