T
- the bound type. The injected is always assignable to this type.public interface Binding<T> extends Element
Bindings are created in several ways:
bind()
and bindConstant()
statements:
bind(Service.class).annotatedWith(Red.class).to(ServiceImpl.class); bindConstant().annotatedWith(ServerHost.class).to(args[0]);
pointer
annotations
or by using its annotated
or
default constructor.providers
, by delegating to the binding for the provided type.They exist on both modules and on injectors, and their behaviour is different for each:
Modifier and Type | Method and Description |
---|---|
<V> V |
acceptScopingVisitor(BindingScopingVisitor<V> visitor)
Accepts a scoping visitor.
|
<V> V |
acceptTargetVisitor(BindingTargetVisitor<? super T,V> visitor)
Accepts a target visitor.
|
Key<T> |
getKey()
Returns the key for this binding.
|
Provider<T> |
getProvider()
Returns the scoped provider guice uses to fulfill requests for this
binding.
|
acceptVisitor, applyTo, getSource
Provider<T> getProvider()
UnsupportedOperationException
- when invoked on a Binding
created via Elements.getElements(com.google.inject.Module...)
. This
method is only supported on Binding
s returned from an injector.<V> V acceptTargetVisitor(BindingTargetVisitor<? super T,V> visitor)
visitor
- to call back on<V> V acceptScopingVisitor(BindingScopingVisitor<V> visitor)
visitor
- to call back onCopyright © 2006-2015 Google, Inc.. All Rights Reserved.