Interface Binder


public interface Binder
An object passed to a Module by the DI container during initialization, that provides the API for the module to bind its services to the container. Note that the default Scope of the bound objects is normally "singleton" and can be changed to "no scope" or a custom scope via a corresponding method of a binding builder. E.g. see BindingBuilder.in(Scope).
Since:
3.1
  • Method Summary

    Modifier and Type Method Description
    <T> BindingBuilder<T> bind​(Class<T> interfaceType)
    Starts an unnamed binding of a specific interface.
    <T> BindingBuilder<T> bind​(Key<T> key)
    Starts a binding of a specific interface based on a provided binding key.
    <T> ListBuilder<T> bindList​(Class<T> valueType)
    Starts a binding of a java.util.List<T> distinguished by its values type.
    <T> ListBuilder<T> bindList​(Class<T> valueType, String bindingName)
    Starts a binding of a java.util.List<T> distinguished by its values type and binding name.
    <T> MapBuilder<T> bindMap​(Class<T> valueType)
    Starts a binding of a java.util.Map<String, T> distinguished by its values type.
    <T> MapBuilder<T> bindMap​(Class<T> valueType, String bindingName)
    Starts a binding of a java.util.Map<String, T> distinguished by its values type and binding name.
    <T> DecoratorBuilder<T> decorate​(Class<T> interfaceType)  
    <T> DecoratorBuilder<T> decorate​(Key<T> key)  
  • Method Details

    • bind

      <T> BindingBuilder<T> bind​(Class<T> interfaceType)
      Starts an unnamed binding of a specific interface. Binding should continue using returned BindingBuilder.
    • bind

      <T> BindingBuilder<T> bind​(Key<T> key)
      Starts a binding of a specific interface based on a provided binding key. This method is more generic than bind(Class) and allows to create named bindings in addition to default ones. Binding should continue using returned BindingBuilder.
    • bindMap

      <T> MapBuilder<T> bindMap​(Class<T> valueType)
      Starts a binding of a java.util.Map<String, T> distinguished by its values type. Map binding should continue using returned MapBuilder. This is a type safe way of binding a map.
      Since:
      4.0
    • bindMap

      <T> MapBuilder<T> bindMap​(Class<T> valueType, String bindingName)
      Starts a binding of a java.util.Map<String, T> distinguished by its values type and binding name. Map binding should continue using returned MapBuilder. This is a type safe way of binding a map.
      Since:
      4.0
    • bindList

      <T> ListBuilder<T> bindList​(Class<T> valueType, String bindingName)
      Starts a binding of a java.util.List<T> distinguished by its values type and binding name. List binding should continue using returned ListBuilder. This is somewhat equivalent of using "bind(List.class, bindingName)", however returned ListBuilder provides extra DI capabilities.
      Since:
      4.0
    • bindList

      <T> ListBuilder<T> bindList​(Class<T> valueType)
      Starts a binding of a java.util.List<T> distinguished by its values type. List binding should continue using returned ListBuilder. This is somewhat equivalent of using "bind(List.class, bindingName)", however returned ListBuilder provides extra DI capabilities.
      Since:
      4.0
    • decorate

      <T> DecoratorBuilder<T> decorate​(Class<T> interfaceType)
      Since:
      4.0
    • decorate

      <T> DecoratorBuilder<T> decorate​(Key<T> key)
      Since:
      4.0