FactoryCreator { public boolean isDuplicate(FactoryCreator<?,R> factoryCreator){ return templateId.isDuplicate(factoryCreator.templateId); } FactoryCreator(FactoryTemplateId<F> templateId, Scope scope, Function<FactoryContext<R>, F> creator); @Override String toString(); boolean match(Class<?> clazzMatch,String name); boolean match(Class<?> clazzMatch); boolean matchLiveObjectClass(Class<?> liveObjectCLass); boolean isDuplicate(FactoryCreator<?,R> factoryCreator); F create(FactoryContext<R> context); Scope getScope(); boolean isEmpty(); @SuppressWarnings("unchecked") void fillFromExistingFactoryTree(Map<FactoryCreatorIdentifier, FactoryBase<?,?>> classToFactory); F createNew(FactoryContext<R> context); void reset(); FactoryCreator<F,R> copy();  }
@Test public void test_duplicate(){ FactoryCreator<ExampleFactoryA,ExampleFactoryA> factoryCreator1 = new FactoryCreator<>(new FactoryTemplateId<>(ExampleFactoryA.class, null), Scope.PROTOTYPE, context -> { return new ExampleFactoryA(); }); FactoryCreator<ExampleFactoryA,ExampleFactoryA> factoryCreator2 = new FactoryCreator<>(new FactoryTemplateId<>(ExampleFactoryA.class, null), Scope.PROTOTYPE, context -> { return new ExampleFactoryA(); }); Assertions.assertTrue(factoryCreator1.isDuplicate(factoryCreator2)); }
@Test public void test_duplicate2(){ FactoryCreator<ExampleFactoryA,ExampleFactoryA> factoryCreator1 = new FactoryCreator<>(new FactoryTemplateId<>(ExampleFactoryA.class, "123"), Scope.PROTOTYPE, context -> { return new ExampleFactoryA(); }); FactoryCreator<ExampleFactoryA,ExampleFactoryA> factoryCreator2 = new FactoryCreator<>(new FactoryTemplateId<>(ExampleFactoryA.class, "123"), Scope.PROTOTYPE, context -> { return new ExampleFactoryA(); }); Assertions.assertTrue(factoryCreator1.isDuplicate(factoryCreator2)); }
@Test public void test_dduplicate3(){ FactoryCreator<ExampleFactoryA,ExampleFactoryA> factoryCreator1 = new FactoryCreator<>(new FactoryTemplateId<>(ExampleFactoryA.class, ""), Scope.PROTOTYPE, context -> { return new ExampleFactoryA(); }); FactoryCreator<ExampleFactoryA,ExampleFactoryA> factoryCreator2 = new FactoryCreator<>(new FactoryTemplateId<>(ExampleFactoryA.class, "123"), Scope.PROTOTYPE, context -> { return new ExampleFactoryA(); }); Assertions.assertFalse(factoryCreator1.isDuplicate(factoryCreator2)); }
@Test public void test_duplicate4(){ FactoryCreator<ExampleFactoryA,ExampleFactoryA> factoryCreator1 = new FactoryCreator<>(new FactoryTemplateId<>(ExampleFactoryA.class,null), Scope.PROTOTYPE, context -> { return new ExampleFactoryA(); }); FactoryCreator<ExampleFactoryB,ExampleFactoryA> factoryCreator2 = new FactoryCreator<>(new FactoryTemplateId<>(ExampleFactoryB.class,null) , Scope.PROTOTYPE, context -> { return new ExampleFactoryB(); }); Assertions.assertFalse(factoryCreator1.isDuplicate(factoryCreator2)); }