SlidingWindows extends NonMergingWindowFn<Object, IntervalWindow> { static Duration getDefaultPeriod(Duration size) { if (size.isLongerThan(Duration.standardHours(1))) { return Duration.standardHours(1); } if (size.isLongerThan(Duration.standardMinutes(1))) { return Duration.standardMinutes(1); } if (size.isLongerThan(Duration.standardSeconds(1))) { return Duration.standardSeconds(1); } return Duration.millis(1); } private  SlidingWindows(Duration period, Duration size, Duration offset); static SlidingWindows of(Duration size); SlidingWindows every(Duration period); SlidingWindows withOffset(Duration offset); @Override Coder<IntervalWindow> windowCoder(); @Override Collection<IntervalWindow> assignWindows(AssignContext c); Collection<IntervalWindow> assignWindows(Instant timestamp); @Override WindowMappingFn<IntervalWindow> getDefaultWindowMappingFn(); @Override boolean isCompatible(WindowFn<?, ?> other); @Override boolean assignsToOneWindow(); @Override void verifyCompatibility(WindowFn<?, ?> other); @Override void populateDisplayData(DisplayData.Builder builder); Duration getPeriod(); Duration getSize(); Duration getOffset(); @Experimental(Kind.OUTPUT_TIME) @Override Instant getOutputTime(Instant inputTimestamp, IntervalWindow window); @Override boolean equals(@Nullable Object object); @Override int hashCode();  }
@Test public void testDefaultPeriods() throws Exception { assertEquals( Duration.standardHours(1), SlidingWindows.getDefaultPeriod(Duration.standardDays(1))); assertEquals( Duration.standardHours(1), SlidingWindows.getDefaultPeriod(Duration.standardHours(2))); assertEquals( Duration.standardMinutes(1), SlidingWindows.getDefaultPeriod(Duration.standardHours(1))); assertEquals( Duration.standardMinutes(1), SlidingWindows.getDefaultPeriod(Duration.standardMinutes(10))); assertEquals( Duration.standardSeconds(1), SlidingWindows.getDefaultPeriod(Duration.standardMinutes(1))); assertEquals( Duration.standardSeconds(1), SlidingWindows.getDefaultPeriod(Duration.standardSeconds(10))); assertEquals(Duration.millis(1), SlidingWindows.getDefaultPeriod(Duration.standardSeconds(1))); assertEquals(Duration.millis(1), SlidingWindows.getDefaultPeriod(Duration.millis(10))); assertEquals(Duration.millis(1), SlidingWindows.getDefaultPeriod(Duration.millis(1))); }