@Test public void testLeftInsertSet() { EventList<Object> source = new BasicEventList<>(); source.add("Chevy"); source.add("Chevy"); source.add("Ford"); UniqueList<Object> uniqueList = new UniqueList<>(source); ListConsistencyListener.install(uniqueList); source.set(1, "Datsun"); }
@Override public E set(int index, E value) { if(index < 0 || index >= size()) throw new IndexOutOfBoundsException("Cannot set at " + index + " on list of size " + size()); updates.beginEvent(true); int startIndex = getSourceIndex(index) + 1; int endIndex = getEndIndex(index); if(endIndex > startIndex) { ((SortedList)source).subList(startIndex, endIndex).clear(); } E result = super.set(index, value); updates.commitEvent(); return result; }
UniqueList extends TransformedList<E, E> { @Override public E set(int index, E value) { if(index < 0 || index >= size()) throw new IndexOutOfBoundsException("Cannot set at " + index + " on list of size " + size()); updates.beginEvent(true); int startIndex = getSourceIndex(index) + 1; int endIndex = getEndIndex(index); if(endIndex > startIndex) { ((SortedList)source).subList(startIndex, endIndex).clear(); } E result = super.set(index, value); updates.commitEvent(); return result; } }
UniqueList extends TransformedList<E, E> { @Override public E set(int index, E value) { if(index < 0 || index >= size()) throw new IndexOutOfBoundsException("Cannot set at " + index + " on list of size " + size()); updates.beginEvent(true); int startIndex = getSourceIndex(index) + 1; int endIndex = getEndIndex(index); if(endIndex > startIndex) { ((SortedList)source).subList(startIndex, endIndex).clear(); } E result = super.set(index, value); updates.commitEvent(); return result; } UniqueList(EventList<E> source);  UniqueList(EventList<E> source, Comparator<? super E> comparator); private  UniqueList(SortedList<E> source, Void dummyParameter); }
UniqueList extends TransformedList<E, E> { @Override public E set(int index, E value) { if(index < 0 || index >= size()) throw new IndexOutOfBoundsException("Cannot set at " + index + " on list of size " + size()); updates.beginEvent(true); int startIndex = getSourceIndex(index) + 1; int endIndex = getEndIndex(index); if(endIndex > startIndex) { ((SortedList)source).subList(startIndex, endIndex).clear(); } E result = super.set(index, value); updates.commitEvent(); return result; } 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(); }
UniqueList extends TransformedList<E, E> { @Override public E set(int index, E value) { if(index < 0 || index >= size()) throw new IndexOutOfBoundsException("Cannot set at " + index + " on list of size " + size()); updates.beginEvent(true); int startIndex = getSourceIndex(index) + 1; int endIndex = getEndIndex(index); if(endIndex > startIndex) { ((SortedList)source).subList(startIndex, endIndex).clear(); } E result = super.set(index, value); updates.commitEvent(); return result; } 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();  }