-
@Documented @Retention(RUNTIME) @Target(METHOD) public @interface BindsAnnotates abstract methods of aModulethat delegate bindings. For example, to bindRandomtoSecureRandoma module could declare the following:@Binds abstract Random bindRandom(SecureRandom secureRandom);@Bindsmethods are a drop-in replacement forProvidesmethods that simply return an injected parameter. Prefer@Bindsbecause the generated implementation is likely to be more efficient.A
@Bindsmethod:- 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 @
Providesmethod) and the parameter is the type to which it is bound.
- Must be