TimeRange { public static TimeRange of(TimeSpan timeSpan, int timeSpanOffset) { if (timeSpan == null) { throw new IllegalArgumentException("Time span is null"); } if (timeSpanOffset < 0) { throw new IllegalArgumentException("Time span offset is negative"); } if (timeSpan == TimeSpan.TODAY) { return new TimeRange(true, timeSpan, timeSpanOffset); } return new TimeRange(false, timeSpan, timeSpanOffset); } private  TimeRange(
		boolean includeToday, TimeSpan timeSpan, int timeSpanOffset); static TimeRange of(TimeSpan timeSpan, int timeSpanOffset); LocalDate getEndLocalDate(); LocalDate getStartLocalDate(); TimeSpan getTimeSpan(); int getTimeSpanOffset();  }
@Test public void testOf() { TimeSpan timeSpan = TimeSpan.LAST_7_DAYS; int timeSpanOffset = RandomTestUtil.randomInt(); TimeRange timeRange = TimeRange.of(timeSpan, timeSpanOffset); Assert.assertNotNull(timeRange); Assert.assertEquals(timeSpan, timeRange.getTimeSpan()); Assert.assertEquals(timeSpanOffset, timeRange.getTimeSpanOffset()); }
@Test(expected = IllegalArgumentException.class) public void testOfWithNegativeTimeSpanOffset() { TimeRange.of(TimeSpan.LAST_7_DAYS, -1); }
@Test(expected = IllegalArgumentException.class) public void testOfWithNullKey() { TimeRange.of(null, RandomTestUtil.randomInt()); }