TimeInterval { public static TimeInterval withTypeAndLength(TimeIntervalType type, int length) { if (type == null) { throw new IllegalArgumentException("type cannot be null"); } validateLength(length); return new TimeInterval(type, length); } private  TimeInterval(TimeIntervalType type, long length); static TimeInterval withMillis(long millis); static TimeInterval withTypeAndLength(TimeIntervalType type, int length); DateTime getIntervalStart(DateTime instant); DateTime plus(DateTime instant, int multiple); DateTime minus(DateTime instant, int multiple); boolean isPeriod(); @JsonProperty("length") long getLength(); @JsonProperty("type") TimeIntervalType getType(); @Deprecated long toApproxMillis(); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); static final TimeInterval INFINITE; static final TimeInterval ZERO; }
@Test( groups = "fast", expectedExceptions = {IllegalArgumentException.class}, expectedExceptionsMessageRegExp = "type cannot be null") public void testNullType() { TimeInterval.withTypeAndLength(null, 1); }
@Test( groups = "fast", expectedExceptions = {IllegalArgumentException.class}, expectedExceptionsMessageRegExp = "length cannot be less than one: 0") public void testInvalidLength() { TimeInterval.withTypeAndLength(TimeIntervalType.DAY, 0); }