### Question:
UniqueList extends TransformedList<E, E> { public void setComparator(Comparator<? super E> comparator) { if (comparator == null) comparator = (Comparator) GlazedLists.comparableComparator(); ((SortedList<E>) this.source).setComparator(comparator); } UniqueList(EventList<E> source);  UniqueList(EventList<E> source, Comparator<? super E> comparator); private  UniqueList(SortedList<E> source, Void dummyParameter); static UniqueList<E> create(EventList<E> source); void setComparator(Comparator<? super E> comparator); @Override int size(); @Override E remove(int index); @Override E set(int index, E value); @Override int indexOf(Object element); @Override void listChanged(ListEvent<E> listChanges); int getCount(int index); int getCount(E value); List<E> getAll(int index); List<E> getAll(E value); @Override void dispose();  }### Answer:
@Test public void testReSortSource() { BasicEventList<Integer> sourceList = new BasicEventList<>(); SortedList<Integer> sortedList = new SortedList<>(sourceList); UniqueList<Integer> uniqueList = new UniqueList<>(sortedList); for(int i = 0; i < 1000; i++) { sourceList.add(new Integer(random.nextInt(100))); } SortedSet<Integer> uniqueSource = new TreeSet<>(); uniqueSource.addAll(sourceList); List<Integer> controlList = new ArrayList<>(); controlList.addAll(uniqueSource); assertEquals(uniqueList, controlList); sortedList.setComparator(null); assertEquals(uniqueList, controlList); sortedList.setComparator(GlazedLists.reverseComparator()); assertEquals(uniqueList, controlList); }
@Test public void testSetComparator() { final BasicEventList<String> source = new BasicEventList<>(); final UniqueList<String> uniqueList = new UniqueList<>(source, GlazedListsTests.getFirstLetterComparator()); ListConsistencyListener.install(uniqueList); source.add("Black"); source.add("Blind"); source.add("Bling"); assertEquals(1, uniqueList.size()); assertEquals("Black", uniqueList.get(0)); uniqueList.setComparator(GlazedListsTests.getLastLetterComparator()); assertEquals(3, uniqueList.size()); assertEquals("Blind", uniqueList.get(0)); assertEquals("Bling", uniqueList.get(1)); assertEquals("Black", uniqueList.get(2)); uniqueList.setComparator(GlazedListsTests.getFirstLetterComparator()); assertEquals(1, uniqueList.size()); assertEquals("Black", uniqueList.get(0)); uniqueList.setComparator(null); assertEquals(3, uniqueList.size()); assertEquals("Black", uniqueList.get(0)); assertEquals("Blind", uniqueList.get(1)); assertEquals("Bling", uniqueList.get(2)); }