@Test public void testSetComparator() { EventList<String> source = new BasicEventList<>(); source.addAll(GlazedListsTests.stringToList("AAaaaBBBBbCCCddd")); SeparatorList<String> separatorList = new SeparatorList<>(source, GlazedLists.caseInsensitiveComparator(), 0, Integer.MAX_VALUE); ListConsistencyListener<String> listConsistencyListener = ListConsistencyListener.install(separatorList); listConsistencyListener.setPreviousElementTracked(false); assertSeparatorEquals(separatorList.get(0), 5, "A"); assertSeparatorEquals(separatorList.get(6), 5, "B"); assertSeparatorEquals(separatorList.get(12), 3, "C"); assertSeparatorEquals(separatorList.get(16), 3, "d"); assertEquals(20, separatorList.size()); separatorList.setComparator(new CaseComparator()); assertSeparatorEquals(separatorList.get(0), 7, "a"); assertSeparatorEquals(separatorList.get(8), 9, "A"); assertEquals(18, separatorList.size()); source.addAll(5, GlazedListsTests.stringToList("aaaA")); assertSeparatorEquals(separatorList.get(0), 10, "a"); assertSeparatorEquals(separatorList.get(11), 10, "A"); assertEquals(22, separatorList.size()); separatorList.setComparator(GlazedLists.caseInsensitiveComparator()); assertSeparatorEquals(separatorList.get(0), 9, "A"); assertSeparatorEquals(separatorList.get(10), 5, "B"); assertSeparatorEquals(separatorList.get(16), 3, "C"); assertSeparatorEquals(separatorList.get(20), 3, "d"); assertEquals(24, separatorList.size()); }
public void setComparator(Comparator<E> comparator) { final boolean isEmpty = isEmpty(); if (!isEmpty) { updates.beginEvent(); updates.addDelete(0, size() - 1); } SortedList<E> sortedList = (SortedList<E>)separatorSource.source; sortedList.setComparator(comparator); if (!isEmpty) { rebuildCollapsedElements(); updates.addInsert(0, size() - 1); updates.commitEvent(); } else { separatorSource.grouper.setComparator(comparator); } }
SeparatorList extends TransformedList<E, E> { public void setComparator(Comparator<E> comparator) { final boolean isEmpty = isEmpty(); if (!isEmpty) { updates.beginEvent(); updates.addDelete(0, size() - 1); } SortedList<E> sortedList = (SortedList<E>)separatorSource.source; sortedList.setComparator(comparator); if (!isEmpty) { rebuildCollapsedElements(); updates.addInsert(0, size() - 1); updates.commitEvent(); } else { separatorSource.grouper.setComparator(comparator); } } }
SeparatorList extends TransformedList<E, E> { public void setComparator(Comparator<E> comparator) { final boolean isEmpty = isEmpty(); if (!isEmpty) { updates.beginEvent(); updates.addDelete(0, size() - 1); } SortedList<E> sortedList = (SortedList<E>)separatorSource.source; sortedList.setComparator(comparator); if (!isEmpty) { rebuildCollapsedElements(); updates.addInsert(0, size() - 1); updates.commitEvent(); } else { separatorSource.grouper.setComparator(comparator); } } SeparatorList(EventList<E> source, Comparator<? super E> comparator, int minimumSizeForSeparator, int defaultLimit); }
SeparatorList extends TransformedList<E, E> { public void setComparator(Comparator<E> comparator) { final boolean isEmpty = isEmpty(); if (!isEmpty) { updates.beginEvent(); updates.addDelete(0, size() - 1); } SortedList<E> sortedList = (SortedList<E>)separatorSource.source; sortedList.setComparator(comparator); if (!isEmpty) { rebuildCollapsedElements(); updates.addInsert(0, size() - 1); updates.commitEvent(); } else { separatorSource.grouper.setComparator(comparator); } } SeparatorList(EventList<E> source, Comparator<? super E> comparator, int minimumSizeForSeparator, int defaultLimit); @Override int size(); void setComparator(Comparator<E> comparator); @Override void listChanged(ListEvent<E> listChanges); @Override void dispose(); }
SeparatorList extends TransformedList<E, E> { public void setComparator(Comparator<E> comparator) { final boolean isEmpty = isEmpty(); if (!isEmpty) { updates.beginEvent(); updates.addDelete(0, size() - 1); } SortedList<E> sortedList = (SortedList<E>)separatorSource.source; sortedList.setComparator(comparator); if (!isEmpty) { rebuildCollapsedElements(); updates.addInsert(0, size() - 1); updates.commitEvent(); } else { separatorSource.grouper.setComparator(comparator); } } SeparatorList(EventList<E> source, Comparator<? super E> comparator, int minimumSizeForSeparator, int defaultLimit); @Override int size(); void setComparator(Comparator<E> comparator); @Override void listChanged(ListEvent<E> listChanges); @Override void dispose();  }