use of com.orientechnologies.orient.object.enhancement.OObjectProxyMethodHandler in project orientdb by orientechnologies.
the class OObjectLazyList method set.
public TYPE set(int index, TYPE element) {
OIdentifiable record;
if (element instanceof OIdentifiable) {
record = (OIdentifiable) element;
if (converted)
converted = false;
if (orphanRemoval && record != null && sourceRecord != null)
((OObjectProxyMethodHandler) sourceRecord.getHandler()).getOrphans().remove(record.getIdentity());
recordList.set(index, record);
} else if (element instanceof Proxy) {
record = (OIdentifiable) OObjectEntitySerializer.getDocument((Proxy) element);
if (orphanRemoval && record != null && sourceRecord != null)
((OObjectProxyMethodHandler) sourceRecord.getHandler()).getOrphans().remove(record.getIdentity());
recordList.set(index, record);
} else {
element = (TYPE) OObjectEntitySerializer.serializeObject(element, getDatabase());
record = getDatabase().getRecordByUserObject(element, false);
if (orphanRemoval && record != null && sourceRecord != null)
((OObjectProxyMethodHandler) sourceRecord.getHandler()).getOrphans().remove(record.getIdentity());
recordList.add(index, record);
}
setDirty();
return (TYPE) super.set(index, element);
}
use of com.orientechnologies.orient.object.enhancement.OObjectProxyMethodHandler in project orientdb by orientechnologies.
the class OObjectLazyList method add.
public boolean add(TYPE element) {
boolean dirty = false;
OIdentifiable record;
if (element instanceof OIdentifiable) {
record = (OIdentifiable) element;
if (converted)
converted = false;
if (recordList.add(record)) {
setDirty();
if (orphanRemoval && record != null && sourceRecord != null)
((OObjectProxyMethodHandler) sourceRecord.getHandler()).getOrphans().remove(record.getIdentity());
return true;
}
} else if (element instanceof Proxy) {
record = (OIdentifiable) OObjectEntitySerializer.getDocument((Proxy) element);
if (orphanRemoval && record != null && sourceRecord != null)
((OObjectProxyMethodHandler) sourceRecord.getHandler()).getOrphans().remove(record.getIdentity());
dirty = recordList.add(record);
} else {
element = (TYPE) OObjectEntitySerializer.serializeObject(element, getDatabase());
record = (OIdentifiable) OObjectEntitySerializer.getDocument((Proxy) element);
if (orphanRemoval && record != null && sourceRecord != null)
((OObjectProxyMethodHandler) sourceRecord.getHandler()).getOrphans().remove(record.getIdentity());
dirty = recordList.add(record);
}
if (dirty)
setDirty();
return super.add(element);
}
Aggregations