SpanImpl extends DataPointImpl implements Span { @Override public <T extends Span> boolean extendsSpan(T span) { return span.intersection(this) != null && ((this.date.getMillis() < span.getDate().getMillis()) || (this.nextDate.getMillis() > span.getNextDate().getMillis())); } SpanImpl(Period period, DateTime d, DateTime next);  SpanImpl(SpanImpl other); void setSpan(SpanImpl other); @Override int compareTo(E other); void setNextDate(DateTime dt); @Override DateTime getNextDate(); @Override int getNextIndex(); @Override int getIndex(); @Override String toString(); @Override int hashCode(); @Override boolean equals(Object obj); @Override boolean extendsSpan(T span); @SuppressWarnings("unchecked") @Override T union(T span); @SuppressWarnings("unchecked") @Override T intersection(T span); static SpanImpl INITIAL; }
@Test public void testExtendsSpan() { final DateTime t = new DateTime(2013, 12, 11, 8, 0, 0); final DateTime t2 = new DateTime(2013, 12, 11, 13, 0, 0); final SpanImpl newSpan = new SpanImpl(Period.ONE_HOUR, t, t2); final DateTime t3 = new DateTime(2013, 12, 11, 12, 0, 0); final DateTime t4 = new DateTime(2013, 12, 11, 16, 0, 0); final SpanImpl newSpan2 = new SpanImpl(Period.ONE_HOUR, t3, t4); assertTrue(newSpan2.extendsSpan(newSpan) && newSpan.extendsSpan(newSpan2)); }