
toothpick.locators.FactoryLocator Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of toothpick-runtime Show documentation
Show all versions of toothpick-runtime Show documentation
'Main Toothpick implementation'
package toothpick.locators;
import toothpick.Factory;
/**
* The locator retrieves a {@link Factory} for a given class.
* In case no generated factory for a given class, we throw a {@link NoFactoryFoundException}.
*
* @see Factory
*/
public class FactoryLocator {
private FactoryLocator() {
}
public static Factory getFactory(Class clazz) {
try {
Class extends Factory> factoryClass = (Class extends Factory>) Class.forName(clazz.getName() + "__Factory");
return factoryClass.newInstance();
} catch (Exception e) {
throw new NoFactoryFoundException(clazz, e);
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy