LongTimeSeries implements TimeSeries<Long> { @JsonIgnore public int getNumberOfInstants() { return timeSeries.size(); } 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 testGetNumberOfInstants() { final LongTimeSeries timeSeries = new LongTimeSeries(TimeBucket.MINUTE); IntStream.range(1, 11) .mapToObj(i -> Instant.ofEpochMilli(1000L * 60 * i)) .forEach(i -> timeSeries.put(i, 1L)); final int numberOfInstants = timeSeries.getNumberOfInstants(); assertEquals(10, numberOfInstants); }