@Test public void testCreatingScoreFunction() { SuperFactory sf = new SuperFactory(); RelatednessFunction func = sf.create("cosine", RelatednessFunction.class); Assert.assertTrue(func != null); Assert.assertEquals(CosineRelatednessFunction.class, func.getClass()); }
public <T> T create(String fullName, Class<T> clazz) { IndraFactory<T> factory; if (fullName != null) { String[] parts = fullName.split(IndraFactory.FACTORY_SEPARATOR); String item; if (parts.length > 1) { factory = getFactory(parts[0], clazz); item = fullName.substring(parts.length, fullName.length()); } else { factory = getFactory(IndraFactory.BUILT_IN_FACTORY, clazz); item = fullName; } return factory != null ? factory.get(item) : null; } else { factory = getFactory(IndraFactory.BUILT_IN_FACTORY, clazz); return factory != null ? factory.getDefault() : null; } }
SuperFactory { public <T> T create(String fullName, Class<T> clazz) { IndraFactory<T> factory; if (fullName != null) { String[] parts = fullName.split(IndraFactory.FACTORY_SEPARATOR); String item; if (parts.length > 1) { factory = getFactory(parts[0], clazz); item = fullName.substring(parts.length, fullName.length()); } else { factory = getFactory(IndraFactory.BUILT_IN_FACTORY, clazz); item = fullName; } return factory != null ? factory.get(item) : null; } else { factory = getFactory(IndraFactory.BUILT_IN_FACTORY, clazz); return factory != null ? factory.getDefault() : null; } } }
SuperFactory { public <T> T create(String fullName, Class<T> clazz) { IndraFactory<T> factory; if (fullName != null) { String[] parts = fullName.split(IndraFactory.FACTORY_SEPARATOR); String item; if (parts.length > 1) { factory = getFactory(parts[0], clazz); item = fullName.substring(parts.length, fullName.length()); } else { factory = getFactory(IndraFactory.BUILT_IN_FACTORY, clazz); item = fullName; } return factory != null ? factory.get(item) : null; } else { factory = getFactory(IndraFactory.BUILT_IN_FACTORY, clazz); return factory != null ? factory.getDefault() : null; } }  }
SuperFactory { public <T> T create(String fullName, Class<T> clazz) { IndraFactory<T> factory; if (fullName != null) { String[] parts = fullName.split(IndraFactory.FACTORY_SEPARATOR); String item; if (parts.length > 1) { factory = getFactory(parts[0], clazz); item = fullName.substring(parts.length, fullName.length()); } else { factory = getFactory(IndraFactory.BUILT_IN_FACTORY, clazz); item = fullName; } return factory != null ? factory.get(item) : null; } else { factory = getFactory(IndraFactory.BUILT_IN_FACTORY, clazz); return factory != null ? factory.getDefault() : null; } }  T create(String fullName, Class<T> clazz); }
SuperFactory { public <T> T create(String fullName, Class<T> clazz) { IndraFactory<T> factory; if (fullName != null) { String[] parts = fullName.split(IndraFactory.FACTORY_SEPARATOR); String item; if (parts.length > 1) { factory = getFactory(parts[0], clazz); item = fullName.substring(parts.length, fullName.length()); } else { factory = getFactory(IndraFactory.BUILT_IN_FACTORY, clazz); item = fullName; } return factory != null ? factory.get(item) : null; } else { factory = getFactory(IndraFactory.BUILT_IN_FACTORY, clazz); return factory != null ? factory.getDefault() : null; } }  T create(String fullName, Class<T> clazz);  }