Why not to use
bind(Logic.class).toInstance(LogicCreator.create(dep));
//ohh we missing dep
then we can do this
class LogicProvider implements Provider<Logic> {
private final SomeDep dep;
@Inject
public LogicProvider(SomeDep dep) {
this.dep = dep;
}
@Override
public Logic get() {
return LogicCreator.create(dep);
}
}
and then
bind(Logic.class).toProvider(LogicProvider.class).asEagerSingleton();
You can even pass SomeDep dep
to your provider as Provider<SomeDep>
and then call providerDep.get()
in LogicCreator.create()
that would be a bit more robust.