FactoryTemplateId { public void serializeTo(F factory) { factory.internal().setTreeBuilderName(name); factory.internal().setTreeBuilderClassUsed(clazz!=null); } @SuppressWarnings("unchecked")  FactoryTemplateId(String name, Class<?> clazz);  FactoryTemplateId(Class<F> clazz, String name); @SuppressWarnings("unchecked")  FactoryTemplateId(F factory); boolean match(Class<?> clazzMatch, String name); boolean match(Class<?> clazzMatch); boolean isDuplicate(FactoryTemplateId<?> templateId); void serializeTo(F factory); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); boolean matchLiveObjectCLass(Class<?> liveObjectClass); final Class<F> clazz; final String name; }
@Test public void test_templateIdPersistence_1_1(){ FactoryTemplateId<ExampleFactoryA> templateId = new FactoryTemplateId<>("test", ExampleFactoryA.class); ExampleFactoryA factory = new ExampleFactoryA(); templateId.serializeTo(factory); FactoryTemplateId<ExampleFactoryA> reRead = new FactoryTemplateId<>(factory); Assertions.assertEquals("test",reRead.name); Assertions.assertEquals(ExampleFactoryA.class,reRead.clazz); }
@Test public void test_templateIdPersistence_0_1(){ FactoryTemplateId<ExampleFactoryA> templateId = new FactoryTemplateId<>(null, ExampleFactoryA.class); ExampleFactoryA factory = new ExampleFactoryA(); templateId.serializeTo(factory); FactoryTemplateId<ExampleFactoryA> reRead = new FactoryTemplateId<>(factory); Assertions.assertEquals(null,reRead.name); Assertions.assertEquals(ExampleFactoryA.class,reRead.clazz); }
@Test public void test_templateIdPersistence_1_0(){ FactoryTemplateId<ExampleFactoryA> templateId = new FactoryTemplateId<>("test", null); ExampleFactoryA factory = new ExampleFactoryA(); templateId.serializeTo(factory); FactoryTemplateId<ExampleFactoryA> reRead = new FactoryTemplateId<>(factory); Assertions.assertEquals("test",reRead.name); Assertions.assertEquals(null,reRead.clazz); }