LongTimeSeries implements TimeSeries<Long> { @Override public boolean equals(final Object obj) { if (this == obj) { return true; } if (null == obj || getClass() != obj.getClass()) { return false; } final LongTimeSeries that = (LongTimeSeries) obj; return new EqualsBuilder() .append(timeBucket, that.timeBucket) .append(timeSeries, that.timeSeries) .isEquals(); } LongTimeSeries(final TimeBucket timeBucket); @JsonCreator  LongTimeSeries(@JsonProperty("timeBucket") final TimeBucket timeBucket,
                          @JsonProperty("timeSeries") final Map<Instant, Long> timeSeries); @Override void put(final Instant instant, final Long value); @JsonIgnore @Override Long get(final Instant instant); void upsert(final Instant instant, final long count); @JsonIgnore SortedSet<Instant> getInstants(); @JsonIgnore int getNumberOfInstants(); SortedMap<Instant, Long> getTimeSeries(); void setTimeSeries(final Map<Instant, Long> timeSeries); TimeBucket getTimeBucket(); @Override boolean equals(final Object obj); @Override int hashCode(); @Override String toString();  }
@Test public void testEquals() { final LongTimeSeries timeSeries1 = new LongTimeSeries(TimeBucket.MINUTE); timeSeries1.upsert(Instant.ofEpochMilli(1000L), 1000L); timeSeries1.upsert(Instant.ofEpochMilli(10000L), 10000L); final LongTimeSeries timeSeries2 = new LongTimeSeries(TimeBucket.MINUTE); timeSeries2.upsert(Instant.ofEpochMilli(1000L), 1000L); timeSeries2.upsert(Instant.ofEpochMilli(10000L), 10000L); final LongTimeSeries timeSeries3 = new LongTimeSeries(TimeBucket.MINUTE); timeSeries3.upsert(Instant.ofEpochMilli(1000L), 1000L); final LongTimeSeries timeSeries4 = new LongTimeSeries(TimeBucket.SECOND); final boolean shouldBeEqual = timeSeries1.equals(timeSeries2); final boolean shouldntBeEqual1 = timeSeries1.equals(timeSeries3); final boolean shouldntBeEqual2 = timeSeries1.equals(timeSeries4); assertEquals(true, shouldBeEqual); assertEquals(false, shouldntBeEqual1); assertEquals(false, shouldntBeEqual2); }