@Documented @Retention(value=RUNTIME) @Target(value=METHOD) public @interface Binds
Modulethat delegate bindings. For example, to bind
SecureRandoma 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.
Providesmethod) and the parameter is the type to which it is bound.
For multibindings, assignability is checked in similar ways:
Set.add(E)when viewed as a member of the return type — the parameter must be assignable to the return type.
Set.addAll(java.util.Collection<? extends E>)when viewed as a member of the return type — if the return type is
Set<E>, the parameter must be assignable to
Collection<? extends E>.
Map.put(K, V)when viewed as a member of a
Vis bound to the return type — the parameter must be assignable to the return type