DataTable { public String getPagesAsString() { StringBuilder sb = new StringBuilder(); if (this.pageNumbers.size() > 1) { sb.append("Pages "); if(pageNumbers.size() > 2 && hasConsecutivePages()) { sb.append(pageNumbers.first()).append("-").append(pageNumbers.last()); return sb.toString(); } int i = 0; for (Integer pageNumber : pageNumbers) { if (i != 0) { sb.append(", "); } sb.append(pageNumber); i++; } } else { sb.append("Page ").append(pageNumbers.iterator().next()); } return sb.toString(); } DataTable(int pageNumber);  DataTable(Collection<Integer> pageNumbers); DataTable addRow(String... dataRow); void addRow(List<String> dataRow); void addRows(List<List<String>> dataRows); List<String> headerRow(); List<String> headerRowIgnoreBlanks(); boolean hasSameHeaderAs(DataTable other); boolean hasSameHeaderBlanksIgnoredAs(DataTable other); boolean hasSameColumnCountAs(DataTable other); List<List<String>> getData(); TreeSet<Integer> getPageNumbers(); DataTable mergeWith(DataTable other); String getPagesAsString(); boolean hasData(); int getColumnsCount(); int getRowsCount(); List<String> getColumn(int c); List<String> getRow(int r); DataTable mergeColumns(int c1, int c2); void addBlankColumn(int index); @Override String toString();  }
@Test public void testPagesAsString() { assertThat(new DataTable(1).getPagesAsString(), is("Page 1")); assertThat(new DataTable(new TreeSet<>(Arrays.asList(2, 3))).getPagesAsString(), is("Pages 2, 3")); assertThat(new DataTable(new TreeSet<>(Arrays.asList(1, 3, 5))).getPagesAsString(), is("Pages 1, 3, 5")); assertThat(new DataTable(new TreeSet<>(Arrays.asList(2, 3, 4, 5))).getPagesAsString(), is("Pages 2-5")); }