@Override public E remove(int index) { return delegate.remove(index); }
@SuppressWarnings({ "rawtypes", "unchecked" }) @Override public Reference reAttach(IdEObject mainObject) { // System.out.println("Re-attaching M " + getReferredObject() + " to " + mainObject + " on " + getIdEObject() + "." + geteReference().getName()); AbstractEList list = (AbstractEList) getIdEObject().eGet(geteReference()); int index = list.indexOf(getReferredObject()); if (index != -1) { try { list.set(index, mainObject); } catch (IllegalArgumentException e) { // e.printStackTrace(); } } // TODO if the old object really does exist multiple times, the new object should also exist multiple times... but it's probably a bug that it's there multiple times in the first place... while (list.contains(getReferredObject())) { list.remove(getReferredObject()); } return new MultiReference(getIdEObject(), mainObject, geteReference()); } }
/** * Removes the object from the list and returns whether the object was actually contained by the list. * This implementation uses {@link #indexOf indexOf} to find the object * and delegates to {@link #remove(int) remove(int)} * in the case that it finds the object. * @param object the object to be removed. * @return whether the object was actually contained by the list. */ @Override public boolean remove(Object object) { int index = indexOf(object); if (index >= 0) { remove(index); return true; } else { return false; } }
/** * Removes each object of the collection from the list and returns whether any object was actually contained by the list. * @param collection the collection of objects to be removed. * @return whether any object was actually contained by the list. */ @Override public boolean removeAll(Collection<?> collection) { boolean modified = false; for (int i = size(); --i >= 0; ) { if (collection.contains(primitiveGet(i))) { remove(i); modified = true; } } return modified; }
/** * Removes from the list each object not contained by the collection * and returns whether any object was actually removed. * This delegates to {@link #remove(int) remove(int)} * in the case that it finds an object that isn't retained. * @param collection the collection of objects to be retained. * @return whether any object was actually removed. */ @Override public boolean retainAll(Collection<?> collection) { boolean modified = false; for (int i = size(); --i >= 0; ) { if (!collection.contains(primitiveGet(i))) { remove(i); modified = true; } } return modified; }