@Test public void testComparisons() { assertTrue("The empty clock should not happen before itself.", getClock().compare(getClock()) != Occurred.CONCURRENTLY); assertTrue("A clock should not happen before an identical clock.", getClock(1, 1, 2).compare(getClock(1, 1, 2)) != Occurred.CONCURRENTLY); assertTrue(" A clock should happen before an identical clock with a single additional event.", getClock(1, 1, 2).compare(getClock(1, 1, 2, 3)) == Occurred.BEFORE); assertTrue("Clocks with different events should be concurrent.", getClock(1).compare(getClock(2)) == Occurred.CONCURRENTLY); assertTrue("Clocks with different events should be concurrent.", getClock(1, 1, 2).compare(getClock(1, 1, 3)) == Occurred.CONCURRENTLY); assertTrue(getClock(2, 2).compare(getClock(1, 2, 2, 3)) == Occurred.BEFORE && getClock(1, 2, 2, 3).compare(getClock(2, 2)) == Occurred.AFTER); }
@Override public Occurred compare(IVersion v) { if(!(v instanceof VectorClock)) throw new IllegalArgumentException("Cannot compare Versions of different types."); return compare(this, (VectorClock) v); }
VectorClock implements IVersion, Serializable, Cloneable { @Override public Occurred compare(IVersion v) { if(!(v instanceof VectorClock)) throw new IllegalArgumentException("Cannot compare Versions of different types."); return compare(this, (VectorClock) v); } }
VectorClock implements IVersion, Serializable, Cloneable { @Override public Occurred compare(IVersion v) { if(!(v instanceof VectorClock)) throw new IllegalArgumentException("Cannot compare Versions of different types."); return compare(this, (VectorClock) v); } VectorClock();  VectorClock(long timestamp); @JsonCreator  VectorClock(@JsonProperty("entries") List<ClockEntry> versions, 
                       @JsonProperty("timestamp") long timestamp); }
VectorClock implements IVersion, Serializable, Cloneable { @Override public Occurred compare(IVersion v) { if(!(v instanceof VectorClock)) throw new IllegalArgumentException("Cannot compare Versions of different types."); return compare(this, (VectorClock) v); } VectorClock();  VectorClock(long timestamp); @JsonCreator  VectorClock(@JsonProperty("entries") List<ClockEntry> versions, 
                       @JsonProperty("timestamp") long timestamp); VectorClock incremented(int nodeId, long time); @Override VectorClock clone(); @Override int hashCode(); @Override boolean equals(Object obj); @Override String toString(); @JsonIgnore long getMaxVersion(); VectorClock merge(VectorClock clock); @Override Occurred compare(IVersion v); static Occurred compare(VectorClock v1, VectorClock v2); long getTimestamp(); List<ClockEntry> getEntries(); }
VectorClock implements IVersion, Serializable, Cloneable { @Override public Occurred compare(IVersion v) { if(!(v instanceof VectorClock)) throw new IllegalArgumentException("Cannot compare Versions of different types."); return compare(this, (VectorClock) v); } VectorClock();  VectorClock(long timestamp); @JsonCreator  VectorClock(@JsonProperty("entries") List<ClockEntry> versions, 
                       @JsonProperty("timestamp") long timestamp); VectorClock incremented(int nodeId, long time); @Override VectorClock clone(); @Override int hashCode(); @Override boolean equals(Object obj); @Override String toString(); @JsonIgnore long getMaxVersion(); VectorClock merge(VectorClock clock); @Override Occurred compare(IVersion v); static Occurred compare(VectorClock v1, VectorClock v2); long getTimestamp(); List<ClockEntry> getEntries();  }