/** * after serialisation or programmatically creation this mus be called first before using the object<br> * to:<br> * -propagate root/parent node to all children (for validation etc)<br> * -init ids *<br> * only call on root<br> *<br> */ private void addBackReferences() { addBackReferences(this,null,this.dataIterationRun+1); }
/** * see: {@link Data#addBackReferences} * @param <T> type * @return usableCopy */ @SuppressWarnings("unchecked") public <T extends Data> T addBackReferences() { if (!this.data.hasBackReferencesFlat()){ this.data.addBackReferences(); } return (T)data; }
/** * -fix all data with same id should be same object * -remove parents that are no not tin the tree * only call on root * */ public void fixDuplicatesAndAddBackReferences() { data.assertRoot(); List<Data> dataList = this.data.fixDuplicateObjects(); for (Data data : dataList) { data.resetBackReferencesFlat(); } this.data.addBackReferences(); }
private void addBackReferences(final Data root, final Data parent, long dataIterationRun){ addParent(parent); this.root=root; getDataDictionary().addBackReferencesToAttributes(this,root); this.visitDataChildrenFlat(data -> data.addBackReferences(root, Data.this,dataIterationRun),dataIterationRun); }