ContinuousSpaceSegment implements Comparable<ContinuousSpaceSegment<C, V>> { @Override public int compareTo(ContinuousSpaceSegment<C, V> other) { int fromComparison = segmentStart.compareTo(other.segmentStart); if (fromComparison == 0) { return segmentEnd.compareTo(other.segmentEnd); } return fromComparison; } ContinuousSpaceSegment(C from, C to, V value);  ContinuousSpaceSegment(RangeBoundary<C> from, RangeBoundary<C> to, V value);  ContinuousSpaceSegment(ContinuousSpaceSegment<C, V> other, V value); boolean contains(RangeBoundary<C> point); boolean contains(C point); RangeBoundary<C> segmentStart(); RangeBoundary<C> segmentEnd(); V value(); @Override int compareTo(ContinuousSpaceSegment<C, V> other); @Override int hashCode(); @Override boolean equals(Object obj); @Override String toString();  }
@Test public void shouldReturnMinusOneWhenOtherSegmentIsLesserThanSegment() { ContinuousSpaceSegment<Integer, String> segment = new ContinuousSpaceSegment<Integer, String>(10, 20, "A"); ContinuousSpaceSegment<Integer, String> other = new ContinuousSpaceSegment<Integer, String>(15, 25, "A"); int result = segment.compareTo(other); assertThat(result).isEqualTo(-1); }
@Test public void shouldReturnZeroWhenOtherSegmentIsSameAsSegment() { ContinuousSpaceSegment<Integer, String> segment = new ContinuousSpaceSegment<Integer, String>(10, 20, "A"); ContinuousSpaceSegment<Integer, String> other = new ContinuousSpaceSegment<Integer, String>(10, 20, "A"); int result = segment.compareTo(other); assertThat(result).isEqualTo(0); }
@Test public void shouldReturnPlusOneWhenOtherSegmentIsGreaterThanSegment() { ContinuousSpaceSegment<Integer, String> segment = new ContinuousSpaceSegment<Integer, String>(10, 20, "A"); ContinuousSpaceSegment<Integer, String> other = new ContinuousSpaceSegment<Integer, String>(5, 15, "A"); int result = segment.compareTo(other); assertThat(result).isEqualTo(1); }