@Test public void testRegisterGraphFactory() { Class<? extends ElementFactory> factoryType = GraphFactory.class; ElementFactory graphFactory1 = createGraphFactory(factoryType); ElementFactory graphFactory2 = createGraphFactory(factoryType); ElementFactory delegateGraphFactory = createDelegateGraphFactory(factoryType); FactoryRegistryImpl factory = new FactoryRegistryImpl(adapter); factory.register(null); assertTrue(factory.getAllFactories().isEmpty()); factory.registerGraphFactory(graphFactory1); assertEquals(graphFactory1, factory.getElementFactory(factoryType)); factory.clear(); factory.registerGraphFactory(delegateGraphFactory); assertEquals(delegateGraphFactory, factory.getElementFactory(factoryType)); factory.clear(); factory.registerGraphFactory(graphFactory1); factory.registerGraphFactory(graphFactory2); assertEquals(graphFactory1, factory.getElementFactory(factoryType)); factory.registerGraphFactory(graphFactory1); factory.registerGraphFactory(delegateGraphFactory); assertEquals(delegateGraphFactory, factory.getElementFactory(factoryType)); }
protected void registerGraphFactory(final ElementFactory item) { final Class<? extends ElementFactory> factoryType = item.getFactoryType(); if (!graphFactories.containsKey(item.getFactoryType()) || item.isDelegateFactory()) { graphFactories.put(factoryType, item); } }
FactoryRegistryImpl implements TypeFactoryRegistry<T> { protected void registerGraphFactory(final ElementFactory item) { final Class<? extends ElementFactory> factoryType = item.getFactoryType(); if (!graphFactories.containsKey(item.getFactoryType()) || item.isDelegateFactory()) { graphFactories.put(factoryType, item); } } }
FactoryRegistryImpl implements TypeFactoryRegistry<T> { protected void registerGraphFactory(final ElementFactory item) { final Class<? extends ElementFactory> factoryType = item.getFactoryType(); if (!graphFactories.containsKey(item.getFactoryType()) || item.isDelegateFactory()) { graphFactories.put(factoryType, item); } } FactoryRegistryImpl(final AdapterManager adapterManager); }
FactoryRegistryImpl implements TypeFactoryRegistry<T> { protected void registerGraphFactory(final ElementFactory item) { final Class<? extends ElementFactory> factoryType = item.getFactoryType(); if (!graphFactories.containsKey(item.getFactoryType()) || item.isDelegateFactory()) { graphFactories.put(factoryType, item); } } FactoryRegistryImpl(final AdapterManager adapterManager); @Override DefinitionFactory<?> getDefinitionFactory(final String id); @Override ElementFactory<?, ?, ?> getElementFactory(final Class<? extends ElementFactory> type); @Override @SuppressWarnings("unchecked") DiagramFactory<?, ?> getDiagramFactory(final String defSetId,
                                                  final Class<? extends Metadata> metadataType); @Override @SuppressWarnings("unchecked") void register(final T item); @Override boolean remove(final T item); @Override void clear(); @Override boolean contains(final T item); @Override boolean isEmpty(); @Override @SuppressWarnings("unchecked") Collection<T> getAllFactories(); @Override DefinitionFactory<?> getDefinitionFactory(final Class<?> type); }
FactoryRegistryImpl implements TypeFactoryRegistry<T> { protected void registerGraphFactory(final ElementFactory item) { final Class<? extends ElementFactory> factoryType = item.getFactoryType(); if (!graphFactories.containsKey(item.getFactoryType()) || item.isDelegateFactory()) { graphFactories.put(factoryType, item); } } FactoryRegistryImpl(final AdapterManager adapterManager); @Override DefinitionFactory<?> getDefinitionFactory(final String id); @Override ElementFactory<?, ?, ?> getElementFactory(final Class<? extends ElementFactory> type); @Override @SuppressWarnings("unchecked") DiagramFactory<?, ?> getDiagramFactory(final String defSetId,
                                                  final Class<? extends Metadata> metadataType); @Override @SuppressWarnings("unchecked") void register(final T item); @Override boolean remove(final T item); @Override void clear(); @Override boolean contains(final T item); @Override boolean isEmpty(); @Override @SuppressWarnings("unchecked") Collection<T> getAllFactories(); @Override DefinitionFactory<?> getDefinitionFactory(final Class<?> type);  }