public class ThrowingProviderBinder extends Object
CheckedProvider
.
You can use a fluent API and custom providers:
ThrowingProviderBinder.create(binder())
.bind(RemoteProvider.class, Customer.class)
.to(RemoteCustomerProvider.class)
.in(RequestScope.class);
or, you can use throwing provider methods:
class MyModule extends AbstractModule {
configure() {
install(ThrowingProviderBinder.forModule(this));
}
@CheckedProvides(RemoteProvider.class)
@RequestScope
Customer provideCustomer(FlakyCustomerCreator creator) throws RemoteException {
return creator.getCustomerOrThrow();
}
}
You also can declare that a CheckedProvider construct a particular class whose constructor throws
an exception:
ThrowingProviderBinder.create(binder())
.bind(RemoteProvider.class, Customer.class)
.providing(CustomerImpl.class)
.in(RequestScope.class);
Modifier and Type | Class and Description |
---|---|
class |
ThrowingProviderBinder.SecondaryBinder<P extends CheckedProvider,T> |
Modifier and Type | Method and Description |
---|---|
<P extends CheckedProvider,T> |
bind(Class<P> interfaceType,
Class<T> clazz) |
<P extends CheckedProvider> |
bind(Class<P> interfaceType,
Type clazz)
Deprecated.
Use
bind(Class, Class) or bind(Class, TypeLiteral) instead. |
<P extends CheckedProvider,T> |
bind(Class<P> interfaceType,
TypeLiteral<T> typeLiteral) |
static ThrowingProviderBinder |
create(Binder binder) |
static Module |
forModule(Module module)
Returns a module that installs @
CheckedProvides methods. |
public static ThrowingProviderBinder create(Binder binder)
public static Module forModule(Module module)
CheckedProvides
methods.@Deprecated public <P extends CheckedProvider> ThrowingProviderBinder.SecondaryBinder<P,?> bind(Class<P> interfaceType, Type clazz)
bind(Class, Class)
or bind(Class, TypeLiteral)
instead.public <P extends CheckedProvider,T> ThrowingProviderBinder.SecondaryBinder<P,T> bind(Class<P> interfaceType, Class<T> clazz)
public <P extends CheckedProvider,T> ThrowingProviderBinder.SecondaryBinder<P,T> bind(Class<P> interfaceType, TypeLiteral<T> typeLiteral)
Copyright © 2006–2018 Google, Inc.. All rights reserved.