-
Notifications
You must be signed in to change notification settings - Fork 115
Factories and Member Injectors
Stéphane Nicolas edited this page May 4, 2016
·
21 revisions
In Toothpick, a Factory<Foo>
is class that produces instance of Foo
.
As Toothpick does not rely on reflection at all, with the idea in mind that performance is awfully slow on Android, it uses Factory
classes that are generated by an annotation processor.
Toothpick annotation processor will create a factory for all classes that have an injected constructor :
public class Foo {
@Inject Foo() {...}
}
Toothpick will then generate a factory :
//a simplified Factory
public final class Foo$$Factory implements Factory<Foo> {
@Override
public Foo createInstance() {
return new Foo();
}
}
Introduce briefly and link to [Factory and MemberInjector registries].