@Test public void testSubList() { int expectedCounter = 0; NotifyOnUpdateList list = new NotifyOnUpdateList(Arrays.asList(5, 4, 3, 2, 1)); assertEquals(expectedCounter, list.getCounter()); List<Integer> subList = list.subList(1, 4); subList.set(0, 16); assertEquals(++expectedCounter, list.getCounter()); }
@Override public List<E> subList(int fromIndex, int toIndex) { return new AbstractNotifyOnUpdateList<E>(this.list.subList(fromIndex, toIndex)) { @Override public void onUpdate() { AbstractNotifyOnUpdateList.this.onUpdate(); } }; }
AbstractNotifyOnUpdateList implements List<E> { @Override public List<E> subList(int fromIndex, int toIndex) { return new AbstractNotifyOnUpdateList<E>(this.list.subList(fromIndex, toIndex)) { @Override public void onUpdate() { AbstractNotifyOnUpdateList.this.onUpdate(); } }; } }
AbstractNotifyOnUpdateList implements List<E> { @Override public List<E> subList(int fromIndex, int toIndex) { return new AbstractNotifyOnUpdateList<E>(this.list.subList(fromIndex, toIndex)) { @Override public void onUpdate() { AbstractNotifyOnUpdateList.this.onUpdate(); } }; } protected  AbstractNotifyOnUpdateList(List<E> list); }
AbstractNotifyOnUpdateList implements List<E> { @Override public List<E> subList(int fromIndex, int toIndex) { return new AbstractNotifyOnUpdateList<E>(this.list.subList(fromIndex, toIndex)) { @Override public void onUpdate() { AbstractNotifyOnUpdateList.this.onUpdate(); } }; } protected  AbstractNotifyOnUpdateList(List<E> list); @Override boolean add(E e); @Override void add(int index, E element); @Override boolean addAll(Collection<? extends E> c); @Override boolean addAll(int index, Collection<? extends E> c); @Override void clear(); @Override boolean contains(Object o); @Override boolean containsAll(Collection<?> c); @Override boolean equals(Object o); @Override E get(int index); @Override int hashCode(); @Override int indexOf(Object o); @Override boolean isEmpty(); @Override Iterator<E> iterator(); @Override int lastIndexOf(Object o); @Override ListIterator<E> listIterator(); @Override ListIterator<E> listIterator(int index); @Override E remove(int index); @Override boolean remove(Object o); @Override boolean removeAll(Collection<?> c); @Override boolean retainAll(Collection<?> c); @Override E set(int index, E element); @Override int size(); @Override List<E> subList(int fromIndex, int toIndex); @Override Object[] toArray(); @Override T[] toArray(T[] a); @Override String toString(); }
AbstractNotifyOnUpdateList implements List<E> { @Override public List<E> subList(int fromIndex, int toIndex) { return new AbstractNotifyOnUpdateList<E>(this.list.subList(fromIndex, toIndex)) { @Override public void onUpdate() { AbstractNotifyOnUpdateList.this.onUpdate(); } }; } protected  AbstractNotifyOnUpdateList(List<E> list); @Override boolean add(E e); @Override void add(int index, E element); @Override boolean addAll(Collection<? extends E> c); @Override boolean addAll(int index, Collection<? extends E> c); @Override void clear(); @Override boolean contains(Object o); @Override boolean containsAll(Collection<?> c); @Override boolean equals(Object o); @Override E get(int index); @Override int hashCode(); @Override int indexOf(Object o); @Override boolean isEmpty(); @Override Iterator<E> iterator(); @Override int lastIndexOf(Object o); @Override ListIterator<E> listIterator(); @Override ListIterator<E> listIterator(int index); @Override E remove(int index); @Override boolean remove(Object o); @Override boolean removeAll(Collection<?> c); @Override boolean retainAll(Collection<?> c); @Override E set(int index, E element); @Override int size(); @Override List<E> subList(int fromIndex, int toIndex); @Override Object[] toArray(); @Override T[] toArray(T[] a); @Override String toString();  }