@Test public void testToString() { VectorClock vc1 = new VectorClock(); vc1.setClock("UnitBBB", 5L); vc1.setClock("UnitAAA", 4L); assertEquals("Expected different serialization", "(UnitAAA4,UnitBBB5)", vc1.toString()); }
@Override public String toString() { Object[] lIDs = keySet().toArray(); Object[] lRequests = values().toArray(); StringBuilder builder = new StringBuilder(); builder.append('('); for (int i = 0; i < lRequests.length; i++) { builder.append(lIDs[i]); builder.append(lRequests[i].toString()); if (i + 1 < lRequests.length) { builder.append(','); } } builder.append(')'); return builder.toString(); }
VectorClock extends TreeMap<String, Long> { @Override public String toString() { Object[] lIDs = keySet().toArray(); Object[] lRequests = values().toArray(); StringBuilder builder = new StringBuilder(); builder.append('('); for (int i = 0; i < lRequests.length; i++) { builder.append(lIDs[i]); builder.append(lRequests[i].toString()); if (i + 1 < lRequests.length) { builder.append(','); } } builder.append(')'); return builder.toString(); } }
VectorClock extends TreeMap<String, Long> { @Override public String toString() { Object[] lIDs = keySet().toArray(); Object[] lRequests = values().toArray(); StringBuilder builder = new StringBuilder(); builder.append('('); for (int i = 0; i < lRequests.length; i++) { builder.append(lIDs[i]); builder.append(lRequests[i].toString()); if (i + 1 < lRequests.length) { builder.append(','); } } builder.append(')'); return builder.toString(); }  }
VectorClock extends TreeMap<String, Long> { @Override public String toString() { Object[] lIDs = keySet().toArray(); Object[] lRequests = values().toArray(); StringBuilder builder = new StringBuilder(); builder.append('('); for (int i = 0; i < lRequests.length; i++) { builder.append(lIDs[i]); builder.append(lRequests[i].toString()); if (i + 1 < lRequests.length) { builder.append(','); } } builder.append(')'); return builder.toString(); }  Long incrementClock(String unit); void setClock(String unit, long value); Long getClock(String unit); @Override Long get(Object unit); @Override VectorClock clone(); @Override String toString(); static VectorClock parseVectorClock(String serializedVectorClock); static VectorClockComparison compare(VectorClock clock1, VectorClock clock2); }
VectorClock extends TreeMap<String, Long> { @Override public String toString() { Object[] lIDs = keySet().toArray(); Object[] lRequests = values().toArray(); StringBuilder builder = new StringBuilder(); builder.append('('); for (int i = 0; i < lRequests.length; i++) { builder.append(lIDs[i]); builder.append(lRequests[i].toString()); if (i + 1 < lRequests.length) { builder.append(','); } } builder.append(')'); return builder.toString(); }  Long incrementClock(String unit); void setClock(String unit, long value); Long getClock(String unit); @Override Long get(Object unit); @Override VectorClock clone(); @Override String toString(); static VectorClock parseVectorClock(String serializedVectorClock); static VectorClockComparison compare(VectorClock clock1, VectorClock clock2); static final Pattern MACHINE_PATTERN; }