@Test public void testRemove() { EventList<String> sourceList = new BasicEventList<>(); GroupingList<String> groupList = GroupingList.create(sourceList); ListConsistencyListener<List<String>> listConsistencyListener = ListConsistencyListener.install(groupList); listConsistencyListener.setPreviousElementTracked(false); assertEquals(0, groupList.size()); sourceList.addAll(GlazedListsTests.stringToList("ABCDD")); groupList.remove(2); assertEquals(3, groupList.size()); assertEquals(GlazedListsTests.stringToList("A"), groupList.get(0)); assertEquals(GlazedListsTests.stringToList("B"), groupList.get(1)); assertEquals(GlazedListsTests.stringToList("DD"), groupList.get(2)); groupList.remove(2); assertEquals(2, groupList.size()); assertEquals(GlazedListsTests.stringToList("A"), groupList.get(0)); assertEquals(GlazedListsTests.stringToList("B"), groupList.get(1)); groupList.remove(GlazedListsTests.stringToList("A")); assertEquals(1, groupList.size()); assertEquals(GlazedListsTests.stringToList("B"), groupList.get(0)); }
@Override public List<E> remove(int index) { if(index < 0 || index >= size()) throw new IndexOutOfBoundsException("Cannot remove at " + index + " on list of size " + size()); final List<E> removed = get(index); final List<E> result = new ArrayList<>(removed); removed.clear(); return result; }
GroupingList extends TransformedList<E, List<E>> { @Override public List<E> remove(int index) { if(index < 0 || index >= size()) throw new IndexOutOfBoundsException("Cannot remove at " + index + " on list of size " + size()); final List<E> removed = get(index); final List<E> result = new ArrayList<>(removed); removed.clear(); return result; } }
GroupingList extends TransformedList<E, List<E>> { @Override public List<E> remove(int index) { if(index < 0 || index >= size()) throw new IndexOutOfBoundsException("Cannot remove at " + index + " on list of size " + size()); final List<E> removed = get(index); final List<E> result = new ArrayList<>(removed); removed.clear(); return result; } GroupingList(EventList<E> source);  GroupingList(EventList<E> source, Comparator<? super E> comparator); private  GroupingList(SortedList<E> source, Comparator<? super E> comparator, Void dummyParameter); }
GroupingList extends TransformedList<E, List<E>> { @Override public List<E> remove(int index) { if(index < 0 || index >= size()) throw new IndexOutOfBoundsException("Cannot remove at " + index + " on list of size " + size()); final List<E> removed = get(index); final List<E> result = new ArrayList<>(removed); removed.clear(); return result; } GroupingList(EventList<E> source);  GroupingList(EventList<E> source, Comparator<? super E> comparator); private  GroupingList(SortedList<E> source, Comparator<? super E> comparator, Void dummyParameter); static GroupingList<E> create(EventList<E> source); int indexOfGroup(E groupElement); void setComparator(Comparator<? super E> comparator); @Override void listChanged(ListEvent<E> listChanges); @Override List<E> get(int index); @Override List<E> remove(int index); @Override List<E> set(int index, List<E> value); @Override void add(int index, List<E> value); @Override int size(); @Override void dispose(); }
GroupingList extends TransformedList<E, List<E>> { @Override public List<E> remove(int index) { if(index < 0 || index >= size()) throw new IndexOutOfBoundsException("Cannot remove at " + index + " on list of size " + size()); final List<E> removed = get(index); final List<E> result = new ArrayList<>(removed); removed.clear(); return result; } GroupingList(EventList<E> source);  GroupingList(EventList<E> source, Comparator<? super E> comparator); private  GroupingList(SortedList<E> source, Comparator<? super E> comparator, Void dummyParameter); static GroupingList<E> create(EventList<E> source); int indexOfGroup(E groupElement); void setComparator(Comparator<? super E> comparator); @Override void listChanged(ListEvent<E> listChanges); @Override List<E> get(int index); @Override List<E> remove(int index); @Override List<E> set(int index, List<E> value); @Override void add(int index, List<E> value); @Override int size(); @Override void dispose();  }