@SuppressWarnings("unchecked") @Override public boolean remove(final Object o) { if (super.remove(o)) { if (o instanceof ODocument) ODocumentInternal.removeOwner((ODocument) o, this); fireCollectionChangedEvent(new OMultiValueChangeEvent<T, T>(OMultiValueChangeEvent.OChangeType.REMOVE, (T) o, null, (T) o)); removeNested(o); return true; } return false; }
@Override public void clear() { final Map<Object, T> origValues; if (changeListeners == null) origValues = null; else origValues = new HashMap<Object, T>(this); if (origValues == null) { for (T value : super.values()) if (value instanceof ODocument) { ODocumentInternal.removeOwner((ODocument) value, this); } } super.clear(); if (origValues != null) { for (Map.Entry<Object, T> entry : origValues.entrySet()) { if (entry.getValue() instanceof ODocument) { ODocumentInternal.removeOwner((ODocument) entry.getValue(), this); } fireCollectionChangedEvent(new OMultiValueChangeEvent<Object, T>(OMultiValueChangeEvent.OChangeType.REMOVE, entry.getKey(), null, entry.getValue())); removeNested(entry.getValue()); } } else setDirty(); }
@Override public void clear() { final List<T> origValues; if (changeListeners!=null && changeListeners.isEmpty()) origValues = null; else origValues = new ArrayList<T>(this); if (origValues == null) { for (final T item : this) { if (item instanceof ODocument) ODocumentInternal.removeOwner((ODocument) item, this); } } super.clear(); if (origValues != null) for (int i = origValues.size() - 1; i >= 0; i--) { final T origValue = origValues.get(i); if (origValue instanceof ODocument) ODocumentInternal.removeOwner((ODocument) origValue, this); fireCollectionChangedEvent(new OMultiValueChangeEvent<Integer, T>(OMultiValueChangeEvent.OChangeType.REMOVE, i, null, origValue)); removeNested(origValue); } else setDirty(); }
@Override public T set(int index, T element) { final T oldValue = super.set(index, element); if (oldValue != null && !oldValue.equals(element)) { if (oldValue instanceof ODocument) ODocumentInternal.removeOwner((ODocument) oldValue, this); addOwnerToEmbeddedDoc(element); fireCollectionChangedEvent(new OMultiValueChangeEvent<Integer, T>(OMultiValueChangeEvent.OChangeType.UPDATE, index, element, oldValue)); } addNested(element); return oldValue; }
@Override public T remove(int index) { final T oldValue = super.remove(index); if (oldValue instanceof ODocument) { ODocumentInternal.removeOwner((ODocument) oldValue, this); } fireCollectionChangedEvent(new OMultiValueChangeEvent<Integer, T>(OMultiValueChangeEvent.OChangeType.REMOVE, index, null, oldValue)); removeNested(oldValue); return oldValue; }
public boolean remove(Object o) { final Object old = map.remove(o); if (old != null) { if (o instanceof ODocument) ODocumentInternal.removeOwner((ODocument) o, this); setDirty(); fireCollectionChangedEvent(new OMultiValueChangeEvent<OIdentifiable, OIdentifiable>( OMultiValueChangeEvent.OChangeType.REMOVE, (OIdentifiable) o, null, (OIdentifiable) o)); return true; } return false; }
@Override public void clear() { final Set<T> origValues; if (changeListeners == null ) origValues = null; else origValues = new HashSet<T>(this); if (origValues == null) { for (final T item : this) { if (item instanceof ODocument) ODocumentInternal.removeOwner((ODocument) item, this); } } super.clear(); if (origValues != null) { for (final T item : origValues) { if (item instanceof ODocument) ODocumentInternal.removeOwner((ODocument) item, this); fireCollectionChangedEvent(new OMultiValueChangeEvent<T, T>(OMultiValueChangeEvent.OChangeType.REMOVE, item, null, item)); removeNested(item); } } else setDirty(); }
@Override public T remove(final Object iKey) { boolean containsKey = containsKey(iKey); final T oldValue = super.remove(iKey); if (oldValue instanceof ODocument) ODocumentInternal.removeOwner((ODocument) oldValue, this); if (containsKey) { fireCollectionChangedEvent( new OMultiValueChangeEvent<Object, T>(OMultiValueChangeEvent.OChangeType.REMOVE, iKey, null, oldValue)); removeNested(oldValue); } return oldValue; }
@Override public T put(final Object key, final T value) { if (key == null) throw new IllegalArgumentException("null key not supported by embedded map"); boolean containsKey = containsKey(key); T oldValue = super.put(key, value); if (containsKey && oldValue == value) return oldValue; if (oldValue instanceof ODocument) ODocumentInternal.removeOwner((ODocument) oldValue, this); addOwnerToEmbeddedDoc(value); if (containsKey) fireCollectionChangedEvent(new OMultiValueChangeEvent<Object, T>(OMultiValueChangeEvent.OChangeType.UPDATE, key, value, oldValue)); else fireCollectionChangedEvent(new OMultiValueChangeEvent<Object, T>(OMultiValueChangeEvent.OChangeType.ADD, key, value)); addNested(value); return oldValue; }
} else if (OType.LINK.equals(fieldType)) { final ODocument embeddedDocument = (ODocument) iPropertyValue; ODocumentInternal.removeOwner(embeddedDocument, this);