private void addToList(EStructuralFeature eStructuralFeature, int index, AbstractEList list, EObject referencedObject) throws DeserializeException { EClass referenceEClass = referencedObject.eClass(); if (((EClass) eStructuralFeature.getEType()).isSuperTypeOf(referenceEClass)) { while (list.size() <= index) { list.addUnique(referencedObject); } } else { throw new DeserializeException(-1, referenceEClass.getName() + " cannot be stored in " + eStructuralFeature.getName()); } }
@Override public E remove(int index) { return delegate.remove(index); }
@Override public boolean addAllUnique(int index, Collection<? extends E> collection) { return delegate.addAllUnique(index, collection); }
AbstractEList<EObject> list = (AbstractEList<EObject>) waitingObject.getObject().eGet(waitingObject.getEReference()); if (waitingObject instanceof SingleWaitingObject) { list.addUnique(eObject); } else { ListWaitingObject listWaitingObject = (ListWaitingObject)waitingObject; if (((EClass) waitingObject.getEReference().getEType()).isSuperTypeOf(eObject.eClass())) { while (list.size() <= listWaitingObject.getIndex()) { EObject create = ec.getEPackage().getEFactoryInstance().create(eObject.eClass()); ((IdEObjectImpl)create).setOid(-2); list.addUnique(create); list.setUnique(listWaitingObject.getIndex(), eObject); } else { throw new DeserializeException(waitingObject.getLineNumber(), "Field " + waitingObject.getEReference().getName() + " of "
/** * Adds the object at the given index in the list. * If {@link #isUnique uniqueness} is required, * duplicates will be ignored. * This implementation delegates to {@link #addUnique(int, Object) addUnique(int, E)} * after uniqueness checking. * @param object the object to be added. * @exception IllegalArgumentException if {@link #isUnique uniqueness} is required, * and the object is a duplicate. * @see #addUnique(int, Object) */ @Override public void add(int index, E object) { int size = size(); if (index > size) throw new BasicIndexOutOfBoundsException(index, size); if (isUnique() && contains(object)) { throw new IllegalArgumentException("The 'no duplicates' constraint is violated"); } addUnique(index, object); }
/** * 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; }
/** * Throws an exception. * @exception UnsupportedOperationException always because it's not supported. */ @Override public void set(E1 object) { throw new UnsupportedOperationException(); }
@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()); } }
@Override public void addUnique(E object) { delegate.addUnique(object); }
/** * Adds the object at the end of the list * and returns whether the object was added; * if {@link #isUnique uniqueness} is required, * duplicates will be ignored and <code>false</code> will be returned. * This implementation delegates to {@link #addUnique(Object) addUnique(E)} * after uniqueness checking. * @param object the object to be added. * @return whether the object was added. * @see #addUnique(Object) */ @Override public boolean add(E object) { if (isUnique() && contains(object)) { return false; } else { addUnique(object); return true; } }
/** * Adds each object of the collection at each successive index in the list * and returns whether any objects were added. * If {@link #isUnique uniqueness} is required, * duplicates will be {@link #getNonDuplicates removed} from the collection, * which could even result in an empty collection. * This implementation delegates to {@link #addAllUnique(int, Collection) addAllUnique(int, Collection)} * after uniqueness checking. * @param index the index at which to add. * @param collection the collection of objects to be added. * @return whether any objects were added. * @see #addAllUnique(int, Collection) */ @Override public boolean addAll(int index, Collection<? extends E> collection) { int size = size(); if (index > size) throw new BasicIndexOutOfBoundsException(index, size); if (isUnique()) { collection = getNonDuplicates(collection); } return addAllUnique(index, collection); }
AbstractEList targetList = (AbstractEList)newObject.eGet(eAttribute); for (Object item : list) { targetList.addUnique(item); if (ref != null) { if (eReference.isUnique()) { list.add(ref); } else { list.addUnique(ref); list.addUnique(listObject); } else { throw new BimserverDatabaseException("Unimplemented");
/** * Returns a hash code computed from each object's hash code. * @return a hash code. */ @Override public int hashCode() { int hashCode = 1; for (int i = 0, size = size(); i < size; ++i) { Object object = primitiveGet(i); hashCode = 31 * hashCode + (object == null ? 0 : object.hashCode()); } return hashCode; }
@Override public int size() { return delegate.size(); }
/** * 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; } }
int size = size(); if (list.size() != size) if (useEquals()) Object o1 = primitiveGet(i); Object o2 = objects.next(); if (o1 == null ? o2 != null : !o1.equals(o2)) Object o1 = primitiveGet(i); Object o2 = objects.next(); if (o1 != o2)
if(listFeature instanceof EAttribute){ while (jsonReader.hasNext()) { innerList.add(readPrimitive(jsonReader, listFeature)); EStructuralFeature wv = wrappedObject.eClass().getEStructuralFeature("wrappedValue"); wrappedObject.eSet(wv, readPrimitive(jsonReader, wv)); innerList.add(wrappedObject); EStructuralFeature wv = wrappedObject.eClass().getEStructuralFeature("wrappedValue"); wrappedObject.eSet(wv, readPrimitive(jsonReader, wv)); list.add(wrappedObject); } else { throw new DeserializeException("Expected _v");
/** * Moves the object to the index of the list. * This implementation uses {@link #indexOf} of find the object * and delegates to {@link #move(int, int) move(int, int)}. * @param index the new position for the object in the list. * @param object the object to be moved. * @exception IndexOutOfBoundsException if the index isn't within the size range or the object isn't contained by the list. */ public void move(int index, E object) { move(index, indexOf(object)); }
/** * Adds each object of the collection to the end of the list. * If {@link #isUnique uniqueness} is required, * duplicates will be {@link #getNonDuplicates removed} from the collection, * which could even result in an empty collection. * This implementation delegates to {@link #addAllUnique(Collection) addAllUnique(Collection)} * after uniqueness checking. * @param collection the collection of objects to be added. * @see #addAllUnique(Collection) */ @Override public boolean addAll(Collection<? extends E> collection) { if (isUnique()) { collection = getNonDuplicates(collection); } return addAllUnique(collection); }
@Override public E setUnique(int index, E newValue) { if (model.getModelState() != ModelState.LOADING) { try { if (newValue instanceof String) { model.getBimServerClient().getLowLevelInterface().setStringAttributeAtIndex(model.getTransactionId(), subject.getOid(), feature.getName(), index, (String) newValue); } else if (newValue instanceof Double) { model.getBimServerClient().getLowLevelInterface().setDoubleAttributeAtIndex(model.getTransactionId(), subject.getOid(), feature.getName(), index, (Double) newValue); } else if (newValue instanceof Boolean) { model.getBimServerClient().getLowLevelInterface().setBooleanAttributeAtIndex(model.getTransactionId(), subject.getOid(), feature.getName(), index, (Boolean) newValue); } else if (newValue instanceof Integer) { model.getBimServerClient().getLowLevelInterface().setIntegerAttributeAtIndex(model.getTransactionId(), subject.getOid(), feature.getName(), index, (Integer) newValue); } else if (newValue instanceof IdEObject) { model.getBimServerClient().getLowLevelInterface() .addReference(model.getTransactionId(), subject.getOid(), feature.getName(), ((IdEObject) newValue).getOid()); } else { throw new RuntimeException("Unimplemented " + feature.getEType().getName() + " " + newValue); } } catch (ServerException e) { LOGGER.error("", e); } catch (UserException e) { LOGGER.error("", e); } catch (PublicInterfaceNotFoundException e) { LOGGER.error("", e); } } return delegate.setUnique(index, newValue); }