delight-factories
A simple API for factories based on simple plain Java objects.
Part of Java Delight.
Usage
Create a collection of factories:
FactoryCollection factories = Factories.create();
Define classes for a factory:
private static class MyConfiguration implements Configuration {}
private static class MyDependencies implements Dependencies {}
Register a factory:
factories.register(new Factory<String, MyConfiguration, Dependencies>() {
@Override
public boolean canInstantiate(Configuration conf) {
return (conf instanceof MyConfiguration);
}
@Override
public String create(MyConfiguration conf, Dependencies dependencies) {
return "Hello, World!";
}
});
Instantiate an object:
Object created = factories.create(new MyConfiguration(), new MyDependencies());
// created == "Hello, WorlD!";
Maven Dependency
<dependency>
<groupId>org.javadelight</groupId>
<artifactId>delight-factories</artifactId>
<version>[insert latest version]</version>
</dependency>
This artifact is available on Maven Central and BinTray.