@Documented
@Target(value=METHOD)
@Retention(value=RUNTIME)
public @interface Provides
Dagger forbids injecting null
by default. Component implementations that invoke
@Provides
methods that return null
will throw a NullPointerException
immediately thereafter. @Provides
methods may opt into allowing null
by
annotating the method with any @Nullable
annotation like
javax.annotation.Nullable
or androidx.annotation.Nullable
.
If a @Provides
method is marked @Nullable
, Dagger will only
allow injection into sites that are marked @Nullable
as well. A component that
attempts to pair a @Nullable
provision with a non-@Nullable
injection site
will fail to compile.