@Test public void compareTo() { BinlogDataId _0 = new BinlogDataId("mysql-bin.000117", 4, 40).setOrdinal(0).setOffset(null); BinlogDataId _00 = new BinlogDataId("mysql-bin.000117", 4, 40).setOrdinal(0).setOffset(0); BinlogDataId _1 = new BinlogDataId("mysql-bin.000117", 4, 40).setOrdinal(1).setOffset(null); BinlogDataId _14 = new BinlogDataId("mysql-bin.000117", 14, 40).setOrdinal(0).setOffset(null); BinlogDataId _118 = new BinlogDataId("mysql-bin.000118", 4, 40).setOrdinal(1).setOffset(null); Assert.assertEquals(-1, _0.compareTo(_00)); Assert.assertEquals(1, _00.compareTo(_0)); Assert.assertEquals(-1, _0.compareTo(_1)); Assert.assertEquals(-1, _00.compareTo(_1)); Assert.assertEquals(-1, _00.compareTo(_14)); Assert.assertEquals(-1, _1.compareTo(_14)); Assert.assertEquals(-1, _0.compareTo(_118)); Assert.assertEquals(-1, _1.compareTo(_118)); Assert.assertEquals(-1, _00.compareTo(_118)); Assert.assertEquals(-1, _14.compareTo(_118)); Assert.assertEquals(0, _0.compareTo(_0)); Assert.assertEquals(0, _00.compareTo(_00)); }
@Override public int compareTo(DataId dataId) { BinlogDataId o = (BinlogDataId) dataId; int cmp = getSyncInitMeta().compareTo(o.getSyncInitMeta()); if (cmp != 0) { return cmp; } cmp = Long.compare(tableMapPos, o.tableMapPos); if (cmp != 0) { return cmp; } cmp = Long.compare(dataPos, o.dataPos); if (cmp != 0) { return cmp; } cmp = Integer.compare(ordinal, o.ordinal); if (cmp != 0) { return cmp; } return Objects.equals(offset, o.offset) ? 0 : offset == null ? -1 : o.offset == null ? 1 : Objects.compare(offset, o.offset, Comparator.naturalOrder()); }
BinlogDataId implements DataId { @Override public int compareTo(DataId dataId) { BinlogDataId o = (BinlogDataId) dataId; int cmp = getSyncInitMeta().compareTo(o.getSyncInitMeta()); if (cmp != 0) { return cmp; } cmp = Long.compare(tableMapPos, o.tableMapPos); if (cmp != 0) { return cmp; } cmp = Long.compare(dataPos, o.dataPos); if (cmp != 0) { return cmp; } cmp = Integer.compare(ordinal, o.ordinal); if (cmp != 0) { return cmp; } return Objects.equals(offset, o.offset) ? 0 : offset == null ? -1 : o.offset == null ? 1 : Objects.compare(offset, o.offset, Comparator.naturalOrder()); } }
BinlogDataId implements DataId { @Override public int compareTo(DataId dataId) { BinlogDataId o = (BinlogDataId) dataId; int cmp = getSyncInitMeta().compareTo(o.getSyncInitMeta()); if (cmp != 0) { return cmp; } cmp = Long.compare(tableMapPos, o.tableMapPos); if (cmp != 0) { return cmp; } cmp = Long.compare(dataPos, o.dataPos); if (cmp != 0) { return cmp; } cmp = Integer.compare(ordinal, o.ordinal); if (cmp != 0) { return cmp; } return Objects.equals(offset, o.offset) ? 0 : offset == null ? -1 : o.offset == null ? 1 : Objects.compare(offset, o.offset, Comparator.naturalOrder()); } BinlogDataId(String binlogFileName, long tableMapPos, long dataPos); }
BinlogDataId implements DataId { @Override public int compareTo(DataId dataId) { BinlogDataId o = (BinlogDataId) dataId; int cmp = getSyncInitMeta().compareTo(o.getSyncInitMeta()); if (cmp != 0) { return cmp; } cmp = Long.compare(tableMapPos, o.tableMapPos); if (cmp != 0) { return cmp; } cmp = Long.compare(dataPos, o.dataPos); if (cmp != 0) { return cmp; } cmp = Integer.compare(ordinal, o.ordinal); if (cmp != 0) { return cmp; } return Objects.equals(offset, o.offset) ? 0 : offset == null ? -1 : o.offset == null ? 1 : Objects.compare(offset, o.offset, Comparator.naturalOrder()); } BinlogDataId(String binlogFileName, long tableMapPos, long dataPos); BinlogDataId setOrdinal(int ordinal); BinlogDataId setOffset(Integer offset); String eventId(); String dataId(); @Override boolean equals(Object o); @Override int hashCode(); @Override SyncInitMeta getSyncInitMeta(); @Override int compareTo(DataId dataId); BinlogDataId copyAndSetOrdinal(int ordinal); BinlogDataId copyAndSetOffset(int offset); @Override String toString(); }
BinlogDataId implements DataId { @Override public int compareTo(DataId dataId) { BinlogDataId o = (BinlogDataId) dataId; int cmp = getSyncInitMeta().compareTo(o.getSyncInitMeta()); if (cmp != 0) { return cmp; } cmp = Long.compare(tableMapPos, o.tableMapPos); if (cmp != 0) { return cmp; } cmp = Long.compare(dataPos, o.dataPos); if (cmp != 0) { return cmp; } cmp = Integer.compare(ordinal, o.ordinal); if (cmp != 0) { return cmp; } return Objects.equals(offset, o.offset) ? 0 : offset == null ? -1 : o.offset == null ? 1 : Objects.compare(offset, o.offset, Comparator.naturalOrder()); } BinlogDataId(String binlogFileName, long tableMapPos, long dataPos); BinlogDataId setOrdinal(int ordinal); BinlogDataId setOffset(Integer offset); String eventId(); String dataId(); @Override boolean equals(Object o); @Override int hashCode(); @Override SyncInitMeta getSyncInitMeta(); @Override int compareTo(DataId dataId); BinlogDataId copyAndSetOrdinal(int ordinal); BinlogDataId copyAndSetOffset(int offset); @Override String toString();  }