publicinterfaceProvider<T>{/** * Provides a fully-constructed and injected instance of {@code T}. * * @throws RuntimeException if the injector encounters an error while * providing an instance. For example, if an injectable member on * {@code T} throws an exception, the injector may wrap the exception * and throw it to the caller of {@code get()}. Callers should not try * to handle such exceptions as the behavior may vary across injector * implementations and even different configurations of the same injector. */Tget();}
/** * A {@link Provider} implementation that memoizes the result of a {@link Factory} instance. * * @author Gregory Kick * @since 2.0 */publicfinalclassScopedProvider<T>implementsProvider<T>{privatestaticfinalObjectUNINITIALIZED=newObject();privatefinalFactory<T>factory;privatevolatileObjectinstance=UNINITIALIZED;privateScopedProvider(Factory<T>factory){assertfactory!=null;this.factory=factory;}@SuppressWarnings("unchecked")// cast only happens when result comes from the factory@OverridepublicTget(){// double-check idiom from EJ2: Item 71Objectresult=instance;if(result==UNINITIALIZED){synchronized(this){result=instance;if(result==UNINITIALIZED){instance=result=factory.get();}}}return(T)result;}/** Returns a new scoped provider for the given factory. */publicstatic<T>Provider<T>create(Factory<T>factory){if(factory==null){thrownewNullPointerException();}returnnewScopedProvider<T>(factory);}}
/** * Injects dependencies into the fields and methods on instances of type {@code T}. Ignores the * presence or absence of an injectable constructor. * * @param <T> type to inject members of * * @author Bob Lee * @author Jesse Wilson * @since 2.0 (since 1.0 without the provision that {@link #injectMembers} cannot accept * {@code null}) */publicinterfaceMembersInjector<T>{/** * Injects dependencies into the fields and methods of {@code instance}. Ignores the presence or * absence of an injectable constructor. * * <p>Whenever the object graph creates an instance, it performs this injection automatically * (after first performing constructor injection), so if you're able to let the object graph * create all your objects for you, you'll never need to use this method. * * @param instance into which members are to be injected * @throws NullPointerException if {@code instance} is {@code null} */voidinjectMembers(Tinstance);}
@Generated("dagger.internal.codegen.ComponentProcessor")publicfinalclassTestModule_ProvideTestDataFactoryimplementsFactory<TestData>{privatefinalTestModulemodule;publicTestModule_ProvideTestDataFactory(TestModulemodule){assertmodule!=null;this.module=module;}@OverridepublicTestDataget(){TestDataprovided=module.provideTestData();if(provided==null){thrownewNullPointerException("Cannot return null from a non-@Nullable @Provides method");}returnprovided;}publicstaticFactory<TestData>create(TestModulemodule){returnnewTestModule_ProvideTestDataFactory(module);}}
@Generated("dagger.internal.codegen.ComponentProcessor")publicfinalclassMainActivity_MembersInjectorimplementsMembersInjector<MainActivity>{privatefinalMembersInjector<AppCompatActivity>supertypeInjector;privatefinalProvider<TestData>mDataProvider;publicMainActivity_MembersInjector(MembersInjector<AppCompatActivity>supertypeInjector,Provider<TestData>mDataProvider){assertsupertypeInjector!=null;this.supertypeInjector=supertypeInjector;assertmDataProvider!=null;this.mDataProvider=mDataProvider;}@OverridepublicvoidinjectMembers(MainActivityinstance){if(instance==null){thrownewNullPointerException("Cannot inject members into a null reference");}supertypeInjector.injectMembers(instance);instance.mData=mDataProvider.get();}publicstaticMembersInjector<MainActivity>create(MembersInjector<AppCompatActivity>supertypeInjector,Provider<TestData>mDataProvider){returnnewMainActivity_MembersInjector(supertypeInjector,mDataProvider);}}