FactoryBaseAttribute extends ReferenceBaseAttribute<F,F,A> { @Override public void set(F factory) { this.value=factory; if (root!=null) { root.internal().needRecalculationForBackReferences(); if (factory!=null){ factory.internal().setRootDeepUnchecked(root); } } updateListeners(factory); } FactoryBaseAttribute(); @Override boolean internal_mergeMatch(AttributeMatch<F> value); @Override @SuppressWarnings("unchecked") void internal_fixDuplicateObjects(Map<UUID, FactoryBase<?,RL>> idToDataMap); @Override F get(); @JsonIgnore Optional<F> getOptional(); @Override void set(F factory); @SuppressWarnings("unchecked") @Override void internal_copyTo(AttributeCopy<F> copyAttribute, Function<FactoryBase<?,?>,FactoryBase<?,?>> newCopyInstanceProvider, int level, int maxLevel, List<FactoryBase<?, ?>> oldData, FactoryBase<?, ?> parent, FactoryBase<?, ?> root); @JsonIgnore @Override String getDisplayText(); void internal_deleteFactory(); @Override void internal_merge(F newValue); L instance(); @Override boolean internal_required(); @SuppressWarnings("unchecked") A nullable(); @Override @SuppressWarnings("unchecked") List<ValidationError> internal_validate(FactoryBase<?,?> parent,String attributeVariableName); @Override void internal_visitChildren(Consumer<FactoryBase<?, ?>> consumer, boolean includeViews);  }
@Test public void test_back_references_after_set_double() { ExampleFactoryA exampleFactoryA = new ExampleFactoryA(); ExampleFactoryB factory = new ExampleFactoryB(); ExampleFactoryC exampleFactoryC = new ExampleFactoryC(); factory.referenceAttributeC.set(exampleFactoryC); exampleFactoryA.referenceAttribute.set(factory); exampleFactoryA.internal().finalise(); ExampleFactoryB factoryB = new ExampleFactoryB(); exampleFactoryC.referenceAttribute.set(factoryB); exampleFactoryA.referenceListAttribute.add(factoryB); exampleFactoryA.internal().finalise(); assertEquals(2,factoryB.internal().getParents().size()); }