xref: /aosp_15_r20/external/dagger2/java/dagger/MembersInjector.java (revision f585d8a307d0621d6060bd7e80091fdcbf94fe27)
1*f585d8a3SJacky Wang /*
2*f585d8a3SJacky Wang  * Copyright (C) 2012 The Dagger Authors.
3*f585d8a3SJacky Wang  *
4*f585d8a3SJacky Wang  * Licensed under the Apache License, Version 2.0 (the "License");
5*f585d8a3SJacky Wang  * you may not use this file except in compliance with the License.
6*f585d8a3SJacky Wang  * You may obtain a copy of the License at
7*f585d8a3SJacky Wang  *
8*f585d8a3SJacky Wang  * http://www.apache.org/licenses/LICENSE-2.0
9*f585d8a3SJacky Wang  *
10*f585d8a3SJacky Wang  * Unless required by applicable law or agreed to in writing, software
11*f585d8a3SJacky Wang  * distributed under the License is distributed on an "AS IS" BASIS,
12*f585d8a3SJacky Wang  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13*f585d8a3SJacky Wang  * See the License for the specific language governing permissions and
14*f585d8a3SJacky Wang  * limitations under the License.
15*f585d8a3SJacky Wang  */
16*f585d8a3SJacky Wang 
17*f585d8a3SJacky Wang package dagger;
18*f585d8a3SJacky Wang 
19*f585d8a3SJacky Wang /**
20*f585d8a3SJacky Wang  * Injects dependencies into the fields and methods on instances of type {@code T}. Ignores the
21*f585d8a3SJacky Wang  * presence or absence of an injectable constructor.
22*f585d8a3SJacky Wang  *
23*f585d8a3SJacky Wang  * @param <T> type to inject members of
24*f585d8a3SJacky Wang  *
25*f585d8a3SJacky Wang  * @since 2.0 (since 1.0 without the provision that {@link #injectMembers} cannot accept
26*f585d8a3SJacky Wang  *      {@code null})
27*f585d8a3SJacky Wang  */
28*f585d8a3SJacky Wang public interface MembersInjector<T> {
29*f585d8a3SJacky Wang 
30*f585d8a3SJacky Wang   /**
31*f585d8a3SJacky Wang    * Injects dependencies into the fields and methods of {@code instance}. Ignores the presence or
32*f585d8a3SJacky Wang    * absence of an injectable constructor.
33*f585d8a3SJacky Wang    *
34*f585d8a3SJacky Wang    * <p>Whenever a {@link Component} creates an instance, it performs this injection automatically
35*f585d8a3SJacky Wang    * (after first performing constructor injection), so if you're able to let the component create
36*f585d8a3SJacky Wang    * all your objects for you, you'll never need to use this method.
37*f585d8a3SJacky Wang    *
38*f585d8a3SJacky Wang    * @param instance into which members are to be injected
39*f585d8a3SJacky Wang    * @throws NullPointerException if {@code instance} is {@code null}
40*f585d8a3SJacky Wang    */
injectMembers(T instance)41*f585d8a3SJacky Wang   void injectMembers(T instance);
42*f585d8a3SJacky Wang }
43