@Test public void instanceProviderMap() { AtomicInteger mut = new AtomicInteger(); Key<Optional<InstanceProvider<String>>> key = new Key<java.util.Optional<InstanceProvider<String>>>() {}; Injector injector = Injector.of( OptionalGeneratorModule.create(), ModuleBuilder.create() .bind(String.class).to(() -> "str_" + mut.incrementAndGet()) .bind(key) .build()); java.util.Optional<InstanceProvider<String>> optional = injector.getInstance(key); assertTrue(optional.isPresent()); InstanceProvider<String> provider = optional.get(); System.out.println(provider.get()); System.out.println(provider.get()); }
public static OptionalGeneratorModule create() { return new OptionalGeneratorModule(); }
OptionalGeneratorModule extends AbstractModule { public static OptionalGeneratorModule create() { return new OptionalGeneratorModule(); } }
OptionalGeneratorModule extends AbstractModule { public static OptionalGeneratorModule create() { return new OptionalGeneratorModule(); } private  OptionalGeneratorModule(); }
OptionalGeneratorModule extends AbstractModule { public static OptionalGeneratorModule create() { return new OptionalGeneratorModule(); } private  OptionalGeneratorModule(); static OptionalGeneratorModule create(); }
OptionalGeneratorModule extends AbstractModule { public static OptionalGeneratorModule create() { return new OptionalGeneratorModule(); } private  OptionalGeneratorModule(); static OptionalGeneratorModule create();  }