### Question:
BinlogInfo implements SyncInitMeta<BinlogInfo> { @Override public int compareTo(BinlogInfo o) { if (o == this) { return 0; } if (this == latest || o == earliest) { return 1; } else if (this == earliest || o == latest) { return -1; } int seq = Integer.parseInt(binlogFilename.split("\\.")[1]); int oSeq = Integer.parseInt(o.binlogFilename.split("\\.")[1]); int compare = Integer.compare(seq, oSeq); return compare != 0 ? compare : Long.compare(binlogPosition, o.binlogPosition); } BinlogInfo(String binlogFilename, long binlogPosition); static BinlogInfo withFilenameCheck(String binlogFilename, long binlogPosition); String getBinlogFilename(); long getBinlogPosition(); @Override int compareTo(BinlogInfo o); @Override String toString(); static final BinlogInfo latest; static final BinlogInfo earliest; }### Answer:
@Test public void compareTo() throws Exception { BinlogInfo b_e = BinlogInfo.earliest; BinlogInfo b_l = BinlogInfo.latest; BinlogInfo b__l = BinlogInfo.latest; BinlogInfo b1 = new BinlogInfo("mysql-bin.00001", 0); BinlogInfo b2 = new BinlogInfo("mysql-bin.00002", 0); BinlogInfo b2_1 = new BinlogInfo("mysql-bin.00002", 1); BinlogInfo b2_2 = new BinlogInfo("mysql-bin.00002", 2); BinlogInfo b20_2 = new BinlogInfo("mysql-bin.00020", 2); BinlogInfo b200_2 = new BinlogInfo("mysql-bin.200", 2); BinlogInfo b1200_2 = new BinlogInfo("mysql-bin.1200", 2); assertEquals(b_e.compareTo(b1), -1); assertEquals(b_l.compareTo(b1), 1); assertEquals(b_e.compareTo(b_l), -1); assertEquals(b_l.compareTo(b__l), 0); assertEquals(b1.compareTo(b2), -1); assertEquals(b2.compareTo(b2_1), -1); assertEquals(b2_1.compareTo(b2_2), -1); assertEquals(b2_2.compareTo(b20_2), -1); assertEquals(b20_2.compareTo(b200_2), -1); assertEquals(b200_2.compareTo(b1200_2), -1); }