ScheduleRecurringOnStartup implements ScheduleOnStartup<T> { static boolean differenceGreaterThan(Instant preexistingExecutionTime, Instant potentiallyNewExecutionTime, Duration delta) { final Duration difference = Duration.between(preexistingExecutionTime, potentiallyNewExecutionTime).abs(); return difference.toMillis() > delta.toMillis(); } ScheduleRecurringOnStartup(String instance, T data, Schedule schedule); @Override void apply(Scheduler scheduler, Clock clock, Task<T> task);  }
@Test void test_differenceGreaterThan() { assertTrue(differenceGreaterThan(clock.now(), clock.now().minusSeconds(10), Duration.ofSeconds(1))); assertTrue(differenceGreaterThan(clock.now(), clock.now().plusSeconds(10), Duration.ofSeconds(1))); assertFalse(differenceGreaterThan(clock.now(), clock.now().minusSeconds(10), Duration.ofSeconds(11))); assertFalse(differenceGreaterThan(clock.now(), clock.now().plusSeconds(10), Duration.ofSeconds(11))); }