private <T> DriftClientBindingBuilder bindDriftClient(Class<T> clientInterface, String configPrefix, Class<? extends Annotation> annotation) { Annotation clientAnnotation = getDriftClientAnnotation(clientInterface, annotation); configBinder(binder).bindConfig(DriftClientConfig.class, clientAnnotation, configPrefix); TypeLiteral<DriftClient<T>> typeLiteral = driftClientTypeLiteral(clientInterface); Provider<T> instanceProvider = new DriftClientInstanceProvider<>(clientAnnotation, Key.get(typeLiteral, annotation)); Provider<DriftClient<T>> factoryProvider = new DriftClientProvider<>(clientInterface, clientAnnotation); binder.bind(Key.get(clientInterface, annotation)).toProvider(instanceProvider).in(Scopes.SINGLETON); binder.bind(Key.get(typeLiteral, annotation)).toProvider(factoryProvider).in(Scopes.SINGLETON); if (annotation == DefaultClient.class) { binder.bind(Key.get(clientInterface)).toProvider(instanceProvider).in(Scopes.SINGLETON); binder.bind(Key.get(typeLiteral)).toProvider(factoryProvider).in(Scopes.SINGLETON); } return new DriftClientBindingBuilder(binder, clientAnnotation, configPrefix); }
private <T> DriftClientBindingBuilder bindDriftClient(Class<T> clientInterface, String configPrefix, Class<? extends Annotation> annotation) { Annotation clientAnnotation = getDriftClientAnnotation(clientInterface, annotation); configBinder(binder).bindConfig(DriftClientConfig.class, clientAnnotation, configPrefix); TypeLiteral<DriftClient<T>> typeLiteral = driftClientTypeLiteral(clientInterface); Provider<T> instanceProvider = new DriftClientInstanceProvider<>(clientAnnotation, Key.get(typeLiteral, annotation)); Provider<DriftClient<T>> factoryProvider = new DriftClientProvider<>(clientInterface, clientAnnotation); binder.bind(Key.get(clientInterface, annotation)).toProvider(instanceProvider).in(Scopes.SINGLETON); binder.bind(Key.get(typeLiteral, annotation)).toProvider(factoryProvider).in(Scopes.SINGLETON); if (annotation == DefaultClient.class) { binder.bind(Key.get(clientInterface)).toProvider(instanceProvider).in(Scopes.SINGLETON); binder.bind(Key.get(typeLiteral)).toProvider(factoryProvider).in(Scopes.SINGLETON); } return new DriftClientBindingBuilder(binder, clientAnnotation, configPrefix); }