Package dagger.model

Interface Binding

All Superinterfaces:
BindingGraph.MaybeBinding, BindingGraph.Node

public interface Binding extends BindingGraph.MaybeBinding
The association between a Key and the way in which instances of the key are provided. Includes any dependencies that are needed in order to provide the instances.

If a binding is owned by more than one component, there is one Binding for every owning component.

  • Method Details

    • componentPath

      ComponentPath componentPath()
      Description copied from interface: BindingGraph.MaybeBinding
      The component that owns the binding, or in which the binding is missing.
      Specified by:
      componentPath in interface BindingGraph.MaybeBinding
      Specified by:
      componentPath in interface BindingGraph.Node
    • binding

      @Deprecated default Optional<Binding> binding()
      Deprecated.
      This always returns Optional.of(this).
      Description copied from interface: BindingGraph.MaybeBinding
      The binding, or empty if missing.
      Specified by:
      binding in interface BindingGraph.MaybeBinding
    • dependencies

      com.google.common.collect.ImmutableSet<DependencyRequest> dependencies()
      The dependencies of this binding. The order of the dependencies corresponds to the order in which they will be injected when the binding is requested.
    • bindingElement

      Optional<Element> bindingElement()
      The Element that declares this binding. Absent for binding kinds that are not always declared by exactly one element.

      For example, consider BindingKind.MULTIBOUND_SET. A component with many @IntoSet bindings for the same key will have a synthetic binding that depends on all contributions, but with no identifiying binding element. A @Multibinds method will also contribute a synthetic binding, but since multiple @Multibinds methods can coexist in the same component (and contribute to one single binding), it has no binding element.

    • contributingModule

      Optional<TypeElement> contributingModule()
      The TypeElement of the module which contributes this binding. Absent for bindings that have no binding element.
    • requiresModuleInstance

      boolean requiresModuleInstance()
      Returns true if using this binding requires an instance of the contributingModule().
    • scope

      Optional<Scope> scope()
      The scope of this binding if it has one.
    • isNullable

      boolean isNullable()
      Returns true if this binding may provide null instead of an instance of BindingGraph.MaybeBinding.key(). Nullable bindings cannot be requested from non-nullable dependency requests.
    • isProduction

      boolean isProduction()
      Returns true if this is a production binding, e.g. an @Produces method.
    • kind

      BindingKind kind()
      The kind of binding this instance represents.