LongTimeSeries implements TimeSeries<Long> { @JsonIgnore public SortedSet<Instant> getInstants() { final SortedSet<Instant> instants = new TreeSet<>(); timeSeries .keySet() .stream() .map(l -> getInstantFromLong(timeBucket, l)) .forEach(instants::add); return instants; } 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 testGetInstants() { final LongTimeSeries timeSeries = new LongTimeSeries(TimeBucket.MINUTE); final Set<Instant> instantsToInsert = new HashSet<>(); IntStream.range(1, 11) .mapToObj(i -> Instant.ofEpochMilli(1000L * 60 * i)) .forEach(instantsToInsert::add); instantsToInsert.stream() .forEach(i -> timeSeries.put(i, 1L)); final SortedSet<Instant> instants = timeSeries.getInstants(); assertEquals(instantsToInsert, instants); }