public InMemoryDataStorage(R initialFactory, ChangeSummaryCreator<R,S> changeSummaryCreator){ initialFactory.internal().addBackReferences(); this.initialFactory=initialFactory; this.changeSummaryCreator = changeSummaryCreator; }
private void visitDataChildrenFlat(Consumer<Data> childFactoriesVisitor, long dataIterationRun){ if (this.dataIterationRun==dataIterationRun){ return; } this.dataIterationRun=dataIterationRun; getDataDictionary().visitDataChildren(this,childFactoriesVisitor); }
public String getDisplayText() { if (text==null && data!=null){ return data.internal().getDisplayText(); } return text; }
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); }
@SuppressWarnings("unchecked") private void visitAttributesDualFlat(Data data, BiAttributeVisitor consumer) { getDataDictionary().visitAttributesDualFlat(this,data,consumer); }
private void visitAttributesTripleFlat(Data other1, Data other2, TriAttributeVisitor consumer) { getDataDictionary().visitAttributesTripleFlat(this,other1,other2,consumer); }
/** * 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; }
/** * @return all data including root and no duplicates * */ public List<Data> collectChildrenDeep() { data.assertRoot(); return data.collectChildrenDeep(); }
/**fix all data with same id should be same object * only call on root * */ public void fixDuplicateData() { data.assertRoot(); data.fixDuplicateObjects(); }
private boolean referenceEquals(Data ref1, Data ref2) { if (ref1 == null && ref2 == null) { return true; } if (ref1 == null || ref2 == null) { return false; } return ref1.idEquals(ref2); }
private Data newCopyInstance(Data data) { return getDataDictionary().newCopyInstance(data); }
/**public utility api * @return the api */ public DataUtility utility(){ return new DataUtility(this); }
/** data configurations api. Should be used in the default constructor * @return the configuration api*/ protected DataConfiguration config(){ return new DataConfiguration(this); }
/** * define match logic for full-text search e.g. in tables * * @param matchSearchTextFunction matchSearchTextFunction * */ public void setMatchSearchTextFunction(Function<String,Boolean> matchSearchTextFunction){ data.setMatchSearchTextFunction(matchSearchTextFunction); }
/** * 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 #setDisplayTextDependencies(Attribute[]) * @param attributes the attributes affecting the display text */ public void setDisplayTextDependencies(List<Attribute<?,?>> attributes){ data.setDisplayTextDependencies(attributes); }
/** * copy with same ids and data * @param <T> self * @return scopy */ public <T extends Data> T copy(){ return data.copy(); }
/** * short readable text describing the factory * @param displayTextProvider displayTextProvider */ public void setDisplayTextProvider(Supplier<String> displayTextProvider){ data.setDisplayTextProvider(displayTextProvider); }
/** * data validation * @param validation validation function * @param dependencies attributes which affect the validation * @param <T> this */ public <T> void addValidation(Validation<T> validation, Attribute<?,?>... dependencies){ data.addValidation(validation,dependencies); }