@Test public void noFlushEmptyWindow() { assertFalse(extendableTimeWindow.flushIfReady()); }
public boolean flushIfReady() { if (firstEventTime == null) { return false; } LocalDateTime now = LocalDateTime.now(clock); boolean isTimeToFlush = lastEventTime.plus(minDelay, ChronoUnit.SECONDS).isBefore(now) || firstEventTime.plus(maxDelay, ChronoUnit.SECONDS).isBefore(now); if (isTimeToFlush) { firstEventTime = null; lastEventTime = null; } return isTimeToFlush; }
ExtendableTimeWindow { public boolean flushIfReady() { if (firstEventTime == null) { return false; } LocalDateTime now = LocalDateTime.now(clock); boolean isTimeToFlush = lastEventTime.plus(minDelay, ChronoUnit.SECONDS).isBefore(now) || firstEventTime.plus(maxDelay, ChronoUnit.SECONDS).isBefore(now); if (isTimeToFlush) { firstEventTime = null; lastEventTime = null; } return isTimeToFlush; } }
ExtendableTimeWindow { public boolean flushIfReady() { if (firstEventTime == null) { return false; } LocalDateTime now = LocalDateTime.now(clock); boolean isTimeToFlush = lastEventTime.plus(minDelay, ChronoUnit.SECONDS).isBefore(now) || firstEventTime.plus(maxDelay, ChronoUnit.SECONDS).isBefore(now); if (isTimeToFlush) { firstEventTime = null; lastEventTime = null; } return isTimeToFlush; } ExtendableTimeWindow(long minDelay, long maxDelay);   ExtendableTimeWindow(long minDelay, long maxDelay, Clock clock); }
ExtendableTimeWindow { public boolean flushIfReady() { if (firstEventTime == null) { return false; } LocalDateTime now = LocalDateTime.now(clock); boolean isTimeToFlush = lastEventTime.plus(minDelay, ChronoUnit.SECONDS).isBefore(now) || firstEventTime.plus(maxDelay, ChronoUnit.SECONDS).isBefore(now); if (isTimeToFlush) { firstEventTime = null; lastEventTime = null; } return isTimeToFlush; } ExtendableTimeWindow(long minDelay, long maxDelay);   ExtendableTimeWindow(long minDelay, long maxDelay, Clock clock); void registerEvent(); boolean flushIfReady(); }
ExtendableTimeWindow { public boolean flushIfReady() { if (firstEventTime == null) { return false; } LocalDateTime now = LocalDateTime.now(clock); boolean isTimeToFlush = lastEventTime.plus(minDelay, ChronoUnit.SECONDS).isBefore(now) || firstEventTime.plus(maxDelay, ChronoUnit.SECONDS).isBefore(now); if (isTimeToFlush) { firstEventTime = null; lastEventTime = null; } return isTimeToFlush; } ExtendableTimeWindow(long minDelay, long maxDelay);   ExtendableTimeWindow(long minDelay, long maxDelay, Clock clock); void registerEvent(); boolean flushIfReady();  }