PageRange implements PagesSelection { public boolean intersects(PageRange range) { return (range.getStart() >= start && range.getStart() <= end) || (range.getEnd() >= start && range.getEnd() <= end); } PageRange();  PageRange(int start, int end);  PageRange(int start); int getStart(); int getEnd(); boolean isUnbounded(); boolean intersects(PageRange range); @Override SortedSet<Integer> getPages(int totalNumberOfPage); boolean contains(int page); @Override String toString(); @Override int hashCode(); @Override boolean equals(Object other); static PageRange one(int page);  }
@Test public void testIntersect() { PageRange base = new PageRange(0, 10); PageRange noIntersection = new PageRange(11, 12); PageRange intersecion = new PageRange(5, 15); PageRange included = new PageRange(2, 5); assertTrue(base.intersects(intersecion)); assertTrue(base.intersects(included)); assertFalse(base.intersects(noIntersection)); }