@Test void testUpperBound() { MongoTrackingToken first = MongoTrackingToken.of(time(1000), "0") .advanceTo(time(1001), "1", Duration.ofHours(1)) .advanceTo(time(1002), "2", Duration.ofHours(1)); MongoTrackingToken second = MongoTrackingToken.of(time(1003), "3"); assertEquals(first.advanceTo(time(1003), "3", Duration.ofHours(1)), first.upperBound(second)); }
@Override public TrackingToken upperBound(TrackingToken other) { Assert.isTrue(other instanceof MongoTrackingToken, () -> "Incompatible token type provided."); long timestamp = max(((MongoTrackingToken) other).timestamp, this.timestamp); Map<String, Long> events = new HashMap<>(trackedEvents); events.putAll(((MongoTrackingToken) other).trackedEvents); return new MongoTrackingToken(timestamp, events); }
MongoTrackingToken implements TrackingToken, Serializable { @Override public TrackingToken upperBound(TrackingToken other) { Assert.isTrue(other instanceof MongoTrackingToken, () -> "Incompatible token type provided."); long timestamp = max(((MongoTrackingToken) other).timestamp, this.timestamp); Map<String, Long> events = new HashMap<>(trackedEvents); events.putAll(((MongoTrackingToken) other).trackedEvents); return new MongoTrackingToken(timestamp, events); } }
MongoTrackingToken implements TrackingToken, Serializable { @Override public TrackingToken upperBound(TrackingToken other) { Assert.isTrue(other instanceof MongoTrackingToken, () -> "Incompatible token type provided."); long timestamp = max(((MongoTrackingToken) other).timestamp, this.timestamp); Map<String, Long> events = new HashMap<>(trackedEvents); events.putAll(((MongoTrackingToken) other).trackedEvents); return new MongoTrackingToken(timestamp, events); } protected  MongoTrackingToken(long timestamp, Map<String, Long> trackedEvents); }
MongoTrackingToken implements TrackingToken, Serializable { @Override public TrackingToken upperBound(TrackingToken other) { Assert.isTrue(other instanceof MongoTrackingToken, () -> "Incompatible token type provided."); long timestamp = max(((MongoTrackingToken) other).timestamp, this.timestamp); Map<String, Long> events = new HashMap<>(trackedEvents); events.putAll(((MongoTrackingToken) other).trackedEvents); return new MongoTrackingToken(timestamp, events); } protected  MongoTrackingToken(long timestamp, Map<String, Long> trackedEvents); static MongoTrackingToken of(Instant timestamp, String eventIdentifier); @JsonCreator static MongoTrackingToken of(@JsonProperty("timestamp") Instant timestamp,
                                        @JsonProperty("trackedEvents") Map<String, Long> trackedEvents); MongoTrackingToken advanceTo(Instant timestamp, String eventIdentifier, Duration lookBackTime); Instant getTimestamp(); Map<String, Long> getTrackedEvents(); @JsonIgnore Set<String> getKnownEventIds(); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); @Override TrackingToken lowerBound(TrackingToken other); @Override TrackingToken upperBound(TrackingToken other); @Override boolean covers(TrackingToken other); }
MongoTrackingToken implements TrackingToken, Serializable { @Override public TrackingToken upperBound(TrackingToken other) { Assert.isTrue(other instanceof MongoTrackingToken, () -> "Incompatible token type provided."); long timestamp = max(((MongoTrackingToken) other).timestamp, this.timestamp); Map<String, Long> events = new HashMap<>(trackedEvents); events.putAll(((MongoTrackingToken) other).trackedEvents); return new MongoTrackingToken(timestamp, events); } protected  MongoTrackingToken(long timestamp, Map<String, Long> trackedEvents); static MongoTrackingToken of(Instant timestamp, String eventIdentifier); @JsonCreator static MongoTrackingToken of(@JsonProperty("timestamp") Instant timestamp,
                                        @JsonProperty("trackedEvents") Map<String, Long> trackedEvents); MongoTrackingToken advanceTo(Instant timestamp, String eventIdentifier, Duration lookBackTime); Instant getTimestamp(); Map<String, Long> getTrackedEvents(); @JsonIgnore Set<String> getKnownEventIds(); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); @Override TrackingToken lowerBound(TrackingToken other); @Override TrackingToken upperBound(TrackingToken other); @Override boolean covers(TrackingToken other);  }