@Override public boolean equals(Object obj) { if (obj instanceof LedgerAddress) { return this.compareTo((LedgerAddress) obj) == 0; } return false; }
/** * Tests the Compare method. */ @Test(timeout = 5000) public void testCompare() { val addresses = new ArrayList<LedgerAddress>(); for (int ledgerSeq = 0; ledgerSeq < LEDGER_COUNT; ledgerSeq++) { long ledgerId = (ledgerSeq + 1) * 31; for (long entryId = 0; entryId < ENTRY_COUNT; entryId++) { addresses.add(new LedgerAddress(ledgerSeq, ledgerId, entryId)); } } for (int i = 0; i < addresses.size() / 2; i++) { val a1 = addresses.get(i); val a2 = addresses.get(addresses.size() - i - 1); val result1 = a1.compareTo(a2); val result2 = a2.compareTo(a1); AssertExtensions.assertLessThan("Unexpected when comparing smaller to larger.", 0, result1); AssertExtensions.assertGreaterThan("Unexpected when comparing larger to smaller.", 0, result2); Assert.assertEquals("Unexpected when comparing to itself.", 0, a1.compareTo(a1)); } }
if (result != null && result.compareTo(this.truncationAddress) < 0) { result = this.truncationAddress;
val m2 = m.truncate(truncationAddress); a = m2.getNextAddress(new LedgerAddress(firstLedgerSeq, firstLedgerId, 0), Long.MAX_VALUE); Assert.assertEquals("Unexpected result when input address less than truncation address.", 0, truncationAddress.compareTo(a));