MaskTimestampSetByTimeRange extends KorypheFunction<RBMBackedTimestampSet, RBMBackedTimestampSet> { @Override public RBMBackedTimestampSet apply(final RBMBackedTimestampSet rbmBackedTimestampSet) { RBMBackedTimestampSet cloned = rbmBackedTimestampSet.getShallowClone(); cloned.applyTimeRangeMask(timeUnit.asMilliSeconds(startTime), timeUnit.asMilliSeconds(endTime)); return cloned; } MaskTimestampSetByTimeRange();  MaskTimestampSetByTimeRange(final Long startTime, final Long endTime);  MaskTimestampSetByTimeRange(final Long startTime, final Long endTime, final TimeUnit timeUnit); @Override RBMBackedTimestampSet apply(final RBMBackedTimestampSet rbmBackedTimestampSet); Long getStartTime(); void setStartTime(final Long startTime); Long getEndTime(); void setEndTime(final Long endTime); TimeUnit getTimeUnit(); void setTimeUnit(final TimeUnit timeUnit); @Override boolean equals(final Object o); @Override int hashCode();  }
@Test public void shouldBeAbleToChangeTimeUnit() { final RBMBackedTimestampSet timestampSet = createTimestampSet(); final long instantInDays = instant.toEpochMilli() / 1000 / 60 / 60 / 24; final MaskTimestampSetByTimeRange mask = new MaskTimestampSetByTimeRange.Builder() .startTime(instantInDays) .endTime(instantInDays + 150L) .timeUnit(TimeUnit.DAY) .build(); final RBMBackedTimestampSet output = mask.apply(timestampSet); final RBMBackedTimestampSet expected = new RBMBackedTimestampSet.Builder() .timeBucket(CommonTimeUtil.TimeBucket.MINUTE) .timestamps(Sets.newHashSet(instant, instant.plus(Duration.ofDays(100)))) .build(); assertEquals(expected, output); }