T
- the bound type. The injected is always assignable to this type.Element
ConstructorBinding<T>
, ConvertedConstantBinding<T>
, ExposedBinding<T>
, InstanceBinding<T>
, LinkedKeyBinding<T>
, ProviderBinding<T>
, ProviderInstanceBinding<T>
, ProviderKeyBinding<T>
, UntargettedBinding<T>
BindingImpl
, ExposedBindingImpl
, InstanceBindingImpl
, LinkedBindingImpl
, LinkedProviderBindingImpl
, ProviderInstanceBindingImpl
, UntargettedBindingImpl
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 | 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()
java.lang.UnsupportedOperationException
- when invoked on a Binding
created via Elements.getElements(org.elasticsearch.common.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 on