@Inject
Injector injector = Guice.createInjector(new ShowtimesModule());
bind(MovieRepository.class).to(MovieRepositoryImpl.class);
@ImplementedBy(MovieRepositoryImpl.class)
given(repository.findByCity(new City("barcelona")))
.willReturn(ImmutableSet.of(new Movie("Blade"), new Movie("Runner")));
@Inject
new GoogleHttpClientModule()
@Provides
@Singleton
bind(MovieRepository.class).to(GoogleMovieRepository.class);
@Named("json")
@Provides @Singleton @Named("json")
bind(MovieRepository.class).to(ImdbMovieRepository.class);
Example queries to play with: rutger hauer, liv tyler
@BindingAnnotation
@Json
@Json
bind(HttpRequestFactory.class).annotatedWith(Json.class).toInstance(providesHttpRequestFactory());
bind(HttpRequestFactory.class).annotatedWith(Names.named("json")).toInstance(providesHttpRequestFactory());
@Inject
Multibinder<MovieRepository> multibinder = Multibinder.newSetBinder(binder(), MovieRepository.class);
multibinder.addBinding().to(GoogleMovieRepository.class);
multibinder.addBinding().to(ImdbMovieRepository.class);
Example queries: chicago, brooklyn, phil