Guice's Providers.of() makes it easy to unit test Provider users. Doing the same with Dagger requires a lot of anonymous inner class boilerplate:
@Test public void grinding() {
final Grinder grinder = mock(Grinder.class);
Lazy<Grinder> lazyGrinder = new Lazy<Grinder>() {
public Grinder get() {
return grinder;
}
}
GridingCoffeeMaker coffeeMaker = new GridingCoffeeMaker(grinder);
...
}
Should we add an API like Dagger.lazy() ? I'm tempted to just wait for JDK 8's Project Lambda, which eliminates the boilerplate directly.