@Test public void test_prototype() { FactoryTreeBuilder<ExampleLiveObjectA,ExampleFactoryA> builder = new FactoryTreeBuilder<>(ExampleFactoryA.class, context -> { ExampleFactoryA factoryBases = new ExampleFactoryA(); factoryBases.referenceAttribute.set(context.get(ExampleFactoryB.class)); return factoryBases; }); builder.addFactory(ExampleFactoryB.class, Scope.PROTOTYPE, context -> { ExampleFactoryB factoryBases = new ExampleFactoryB(); factoryBases.stringAttribute.set("123"); return factoryBases; }); ExampleFactoryA root = builder.buildTreeUnvalidated(); FactoryTreeBuilderBasedAttributeSetup<ExampleFactoryA> factoryTreeBuilderBasedAttributeSetup = new FactoryTreeBuilderBasedAttributeSetup<>(builder); factoryTreeBuilderBasedAttributeSetup.applyToRootFactoryDeep(root); List<ExampleFactoryB> possibleValues1 = root.referenceAttribute.internal_createNewPossibleValues(FactoryMetadataManager.getMetadata(ExampleFactoryA.class).getAttributeMetadata(f->f.referenceAttribute)); List<ExampleFactoryB> possibleValues2 = root.referenceAttribute.internal_createNewPossibleValues(FactoryMetadataManager.getMetadata(ExampleFactoryA.class).getAttributeMetadata(f->f.referenceAttribute)); Assertions.assertNotEquals(possibleValues1.get(0),possibleValues2.get(0)); }
public void applyToRootFactoryDeep(R root) { root.internal().serFactoryTreeBuilderBasedAttributeSetupForRoot(this); root.internal().setFactoryTreeBuilder(this.factoryTreeBuilder); factoryTreeBuilder.fillFromExistingFactoryTree(root); root.internal().collectChildrenDeep().forEach(data -> { data.internal().visitAttributesFlat(this::applyToAttribute); }); }
FactoryTreeBuilderBasedAttributeSetup { public void applyToRootFactoryDeep(R root) { root.internal().serFactoryTreeBuilderBasedAttributeSetupForRoot(this); root.internal().setFactoryTreeBuilder(this.factoryTreeBuilder); factoryTreeBuilder.fillFromExistingFactoryTree(root); root.internal().collectChildrenDeep().forEach(data -> { data.internal().visitAttributesFlat(this::applyToAttribute); }); } }
FactoryTreeBuilderBasedAttributeSetup { public void applyToRootFactoryDeep(R root) { root.internal().serFactoryTreeBuilderBasedAttributeSetupForRoot(this); root.internal().setFactoryTreeBuilder(this.factoryTreeBuilder); factoryTreeBuilder.fillFromExistingFactoryTree(root); root.internal().collectChildrenDeep().forEach(data -> { data.internal().visitAttributesFlat(this::applyToAttribute); }); } FactoryTreeBuilderBasedAttributeSetup(FactoryTreeBuilder<?,R> factoryTreeBuilder); }
FactoryTreeBuilderBasedAttributeSetup { public void applyToRootFactoryDeep(R root) { root.internal().serFactoryTreeBuilderBasedAttributeSetupForRoot(this); root.internal().setFactoryTreeBuilder(this.factoryTreeBuilder); factoryTreeBuilder.fillFromExistingFactoryTree(root); root.internal().collectChildrenDeep().forEach(data -> { data.internal().visitAttributesFlat(this::applyToAttribute); }); } FactoryTreeBuilderBasedAttributeSetup(FactoryTreeBuilder<?,R> factoryTreeBuilder); @SuppressWarnings("unchecked") List<FO> createNewFactory(Class<LO> liveObjectClass); void applyToRootFactoryDeep(R root); }
FactoryTreeBuilderBasedAttributeSetup { public void applyToRootFactoryDeep(R root) { root.internal().serFactoryTreeBuilderBasedAttributeSetupForRoot(this); root.internal().setFactoryTreeBuilder(this.factoryTreeBuilder); factoryTreeBuilder.fillFromExistingFactoryTree(root); root.internal().collectChildrenDeep().forEach(data -> { data.internal().visitAttributesFlat(this::applyToAttribute); }); } FactoryTreeBuilderBasedAttributeSetup(FactoryTreeBuilder<?,R> factoryTreeBuilder); @SuppressWarnings("unchecked") List<FO> createNewFactory(Class<LO> liveObjectClass); void applyToRootFactoryDeep(R root);  }