Module dagger
Package dagger

Annotation Type Binds


  • @Documented
    @Retention(RUNTIME)
    @Target(METHOD)
    public @interface Binds
    Annotates abstract methods of a Module that delegate bindings. For example, to bind Random to SecureRandom a module could declare the following: @Binds abstract Random bindRandom(SecureRandom secureRandom);

    @Binds methods are a drop-in replacement for Provides methods that simply return an injected parameter. Prefer @Binds because the generated implementation is likely to be more efficient.

    A @Binds method:

    • Must be abstract.
    • May be scoped.
    • May be qualified.
    • Must have a single parameter whose type is assignable to the return type. The return type declares the bound type (just as it would for a @Provides method) and the parameter is the type to which it is bound.