@Test public void test_getChangedFactories_views() { FactoryBaseTest.XRoot previous = new FactoryBaseTest.XRoot(); FactoryBaseTest.ExampleFactoryAndViewA exampleFactoryAndViewA = new FactoryBaseTest.ExampleFactoryAndViewA(); previous.referenceAttribute.set(exampleFactoryAndViewA); FactoryBaseTest.XFactory xFactory = new FactoryBaseTest.XFactory(); previous.xFactory.set(xFactory); FactoryBaseTest.XRoot update= previous.utility().copy(); update.xFactory.set(null); DataMerger<FactoryBaseTest.XRoot> dataMerger = new DataMerger<>(previous, previous.internal().copy(), update); MergeResult<FactoryBaseTest.XRoot> mergeResult = dataMerger.createMergeResult((p) -> true); Set<FactoryBase<?,FactoryBaseTest.XRoot>> changedFactories=mergeResult.getMergedFactories(); Assertions.assertTrue(changedFactories.contains(previous)); Assertions.assertTrue(changedFactories.contains(exampleFactoryAndViewA)); }
public MergeResult<R> createMergeResult(Function<String,Boolean> permissionChecker) { MergeResult<R> mergeResult = new MergeResult<>(currentData,idToFactory); for (Triple<R> entry : mergeable) { FactoryBase<?,R> originalValue = entry.commonFactory; FactoryBase<?,R> newValue = entry.newFactory; if (newValue==null && originalValue!=null){ entry.currentFactory.internal().visitAttributesForMatch(originalValue, (name,currentAttribute, originalAttribute) -> { if (!currentAttribute.internal_mergeMatch(originalAttribute)){ mergeResult.addConflictInfo(new AttributeDiffInfo(name,entry.currentFactory.getId())); } return true; }); } if (originalValue!=null && newValue!=null){ FactoryBase<?,R> value = entry.currentFactory; value.internal().merge(originalValue, newValue, mergeResult, permissionChecker); } } return mergeResult; }
DataMerger { public MergeResult<R> createMergeResult(Function<String,Boolean> permissionChecker) { MergeResult<R> mergeResult = new MergeResult<>(currentData,idToFactory); for (Triple<R> entry : mergeable) { FactoryBase<?,R> originalValue = entry.commonFactory; FactoryBase<?,R> newValue = entry.newFactory; if (newValue==null && originalValue!=null){ entry.currentFactory.internal().visitAttributesForMatch(originalValue, (name,currentAttribute, originalAttribute) -> { if (!currentAttribute.internal_mergeMatch(originalAttribute)){ mergeResult.addConflictInfo(new AttributeDiffInfo(name,entry.currentFactory.getId())); } return true; }); } if (originalValue!=null && newValue!=null){ FactoryBase<?,R> value = entry.currentFactory; value.internal().merge(originalValue, newValue, mergeResult, permissionChecker); } } return mergeResult; } }
DataMerger { public MergeResult<R> createMergeResult(Function<String,Boolean> permissionChecker) { MergeResult<R> mergeResult = new MergeResult<>(currentData,idToFactory); for (Triple<R> entry : mergeable) { FactoryBase<?,R> originalValue = entry.commonFactory; FactoryBase<?,R> newValue = entry.newFactory; if (newValue==null && originalValue!=null){ entry.currentFactory.internal().visitAttributesForMatch(originalValue, (name,currentAttribute, originalAttribute) -> { if (!currentAttribute.internal_mergeMatch(originalAttribute)){ mergeResult.addConflictInfo(new AttributeDiffInfo(name,entry.currentFactory.getId())); } return true; }); } if (originalValue!=null && newValue!=null){ FactoryBase<?,R> value = entry.currentFactory; value.internal().merge(originalValue, newValue, mergeResult, permissionChecker); } } return mergeResult; } DataMerger(R currentData, R commonData, R newData); }
DataMerger { public MergeResult<R> createMergeResult(Function<String,Boolean> permissionChecker) { MergeResult<R> mergeResult = new MergeResult<>(currentData,idToFactory); for (Triple<R> entry : mergeable) { FactoryBase<?,R> originalValue = entry.commonFactory; FactoryBase<?,R> newValue = entry.newFactory; if (newValue==null && originalValue!=null){ entry.currentFactory.internal().visitAttributesForMatch(originalValue, (name,currentAttribute, originalAttribute) -> { if (!currentAttribute.internal_mergeMatch(originalAttribute)){ mergeResult.addConflictInfo(new AttributeDiffInfo(name,entry.currentFactory.getId())); } return true; }); } if (originalValue!=null && newValue!=null){ FactoryBase<?,R> value = entry.currentFactory; value.internal().merge(originalValue, newValue, mergeResult, permissionChecker); } } return mergeResult; } DataMerger(R currentData, R commonData, R newData); MergeResult<R> createMergeResult(Function<String,Boolean> permissionChecker); MergeDiffInfo<R> mergeIntoCurrent(Function<String,Boolean> permissionChecker); }
DataMerger { public MergeResult<R> createMergeResult(Function<String,Boolean> permissionChecker) { MergeResult<R> mergeResult = new MergeResult<>(currentData,idToFactory); for (Triple<R> entry : mergeable) { FactoryBase<?,R> originalValue = entry.commonFactory; FactoryBase<?,R> newValue = entry.newFactory; if (newValue==null && originalValue!=null){ entry.currentFactory.internal().visitAttributesForMatch(originalValue, (name,currentAttribute, originalAttribute) -> { if (!currentAttribute.internal_mergeMatch(originalAttribute)){ mergeResult.addConflictInfo(new AttributeDiffInfo(name,entry.currentFactory.getId())); } return true; }); } if (originalValue!=null && newValue!=null){ FactoryBase<?,R> value = entry.currentFactory; value.internal().merge(originalValue, newValue, mergeResult, permissionChecker); } } return mergeResult; } DataMerger(R currentData, R commonData, R newData); MergeResult<R> createMergeResult(Function<String,Boolean> permissionChecker); MergeDiffInfo<R> mergeIntoCurrent(Function<String,Boolean> permissionChecker);  }