LongTimeSeries implements TimeSeries<Long> { @Override public int hashCode() { return new HashCodeBuilder(21, 3) .append(timeBucket) .append(timeSeries) .toHashCode(); } 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 testHashcode() { final LongTimeSeries timeSeries1 = new LongTimeSeries(TimeBucket.MINUTE); timeSeries1.upsert(Instant.ofEpochMilli(1000L), 1000L); timeSeries1.upsert(Instant.ofEpochMilli(10000L), 10000L); final int hashCode1 = timeSeries1.hashCode(); final LongTimeSeries timeSeries2 = new LongTimeSeries(TimeBucket.MINUTE); timeSeries2.upsert(Instant.ofEpochMilli(1000L), 1000L); timeSeries2.upsert(Instant.ofEpochMilli(10000L), 10000L); final int hashCode2 = timeSeries2.hashCode(); final LongTimeSeries timeSeries3 = new LongTimeSeries(TimeBucket.MINUTE); timeSeries3.upsert(Instant.ofEpochMilli(1000L), 1000L); final int hashCode3 = timeSeries3.hashCode(); final LongTimeSeries timeSeries4 = new LongTimeSeries(TimeBucket.SECOND); final int hashCode4 = timeSeries4.hashCode(); final boolean shouldBeEqual = hashCode1 == hashCode2; final boolean shouldntBeEqual1 = hashCode1 == hashCode3; final boolean shouldntBeEqual2 = hashCode1 == hashCode4; assertEquals(true, shouldBeEqual); assertEquals(false, shouldntBeEqual1); assertEquals(false, shouldntBeEqual2); }