• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 package coffee;
2 
3 import dagger.Lazy;
4 import javax.inject.Inject;
5 
6 class CoffeeMaker {
7   private final Lazy<Heater> heater; // Create a possibly costly heater only when we use it.
8   private final Pump pump;
9 
CoffeeMaker(Lazy<Heater> heater, Pump pump)10   @Inject CoffeeMaker(Lazy<Heater> heater, Pump pump) {
11     this.heater = heater;
12     this.pump = pump;
13   }
14 
brew()15   public void brew() {
16     heater.get().on();
17     pump.pump();
18     System.out.println(" [_]P coffee! [_]P ");
19     heater.get().off();
20   }
21 }
22