LogRecord implements Comparable<LogRecord> { public int getOffset() { return offset; } LogRecord(int fileID, int offset, TransactionEventRecord event); int getFileID(); int getOffset(); TransactionEventRecord getEvent(); @Override int compareTo(LogRecord o);  }
@Test public void testSortOrder() { long now = System.currentTimeMillis(); List<LogRecord> records = Lists.newArrayList(); for (int i = 0; i < 3; i++) { Commit commit = new Commit((long)i, now - i); LogRecord logRecord = new LogRecord(1, i, commit); records.add(logRecord); } LogRecord logRecord; logRecord = Collections.min(records); Assert.assertTrue(String.valueOf(logRecord.getOffset()), 2 == logRecord.getOffset()); records.remove(logRecord); logRecord = Collections.min(records); Assert.assertTrue(String.valueOf(logRecord.getOffset()), 1 == logRecord.getOffset()); records.remove(logRecord); logRecord = Collections.min(records); Assert.assertTrue(String.valueOf(logRecord.getOffset()), 0 == logRecord.getOffset()); records.remove(logRecord); }