com.google.inject
Class ContainerBuilder.BindingBuilder<T>

java.lang.Object
  extended by com.google.inject.ContainerBuilder.BindingBuilder<T>
Enclosing class:
ContainerBuilder

public class ContainerBuilder.BindingBuilder<T>
extends java.lang.Object

Binds a Key to an implementation in a given scope.


Method Summary
 ContainerBuilder.BindingBuilder<T> in(Scope scope)
          Specifies the scope.
 ContainerBuilder.BindingBuilder<T> in(java.lang.String scopeName)
          Specifies the scope.
 ContainerBuilder.BindingBuilder<T> inContainerScope()
          Specifies container scope (i.e. one instance per container).
 ContainerBuilder.BindingBuilder<T> named(java.lang.String name)
          Sets the name of this binding.
 ContainerBuilder.BindingBuilder<T> preload()
          Instructs the builder to eagerly load this binding when it creates the container.
<I extends T>
ContainerBuilder.BindingBuilder<T>
to(java.lang.Class<I> implementation)
          Binds to instances of the given implementation class.
 ContainerBuilder.BindingBuilder<T> to(ContextualFactory<? extends T> factory)
          Binds to instances from the given factory.
 ContainerBuilder.BindingBuilder<T> to(Factory<? extends T> factory)
          Binds to instances from the given factory.
 ContainerBuilder.BindingBuilder<T> to(T instance)
          Binds to the given instance.
<I extends T>
ContainerBuilder.BindingBuilder<T>
to(TypeLiteral<I> implementation)
          Binds to instances of the given implementation type.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

named

public ContainerBuilder.BindingBuilder<T> named(java.lang.String name)
Sets the name of this binding.


to

public <I extends T> ContainerBuilder.BindingBuilder<T> to(java.lang.Class<I> implementation)
Binds to instances of the given implementation class. The Container will inject the implementation instances as well. Sets the scope based on the @Scoped annotation on the implementation class if present.


to

public <I extends T> ContainerBuilder.BindingBuilder<T> to(TypeLiteral<I> implementation)
Binds to instances of the given implementation type. The Container will inject the implementation instances as well. Sets the scope based on the @Scoped annotation on the implementation class if present.


to

public ContainerBuilder.BindingBuilder<T> to(ContextualFactory<? extends T> factory)
Binds to instances from the given factory.


to

public ContainerBuilder.BindingBuilder<T> to(Factory<? extends T> factory)
Binds to instances from the given factory.


to

public ContainerBuilder.BindingBuilder<T> to(T instance)
Binds to the given instance.


in

public ContainerBuilder.BindingBuilder<T> in(java.lang.String scopeName)
Specifies the scope. References the name passed to ContainerBuilder.put(String, Scope).


in

public ContainerBuilder.BindingBuilder<T> in(Scope scope)
Specifies the scope.


inContainerScope

public ContainerBuilder.BindingBuilder<T> inContainerScope()
Specifies container scope (i.e. one instance per container).


preload

public ContainerBuilder.BindingBuilder<T> preload()
Instructs the builder to eagerly load this binding when it creates the container. Useful for application initialization logic. Currently only supported for container-scoped bindings.