PageRange implements PagesSelection { @Override public String toString() { if (isUnbounded()) { return String.format("%s-", start); } if (start == end) { return String.format("%s", start); } return String.format("%s-%s", start, 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 testToString() { assertEquals("1-2", new PageRange(1, 2).toString()); assertEquals("2", new PageRange(2, 2).toString()); assertEquals("2-", new PageRange(2).toString()); }