• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2015 The Dagger Authors.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package dagger;
18 
19 import static java.lang.annotation.ElementType.TYPE;
20 import static java.lang.annotation.RetentionPolicy.RUNTIME;
21 
22 import java.lang.annotation.Documented;
23 import java.lang.annotation.Retention;
24 import java.lang.annotation.Target;
25 
26 /**
27  * A subcomponent that inherits the bindings from a parent {@link Component} or
28  * {@link Subcomponent}. The details of how to associate a subcomponent with a parent are described
29  * in the documentation for {@link Component}.
30  *
31  * @since 2.0
32  */
33 @Retention(RUNTIME) // Allows runtimes to have specialized behavior interoperating with Dagger.
34 @Target(TYPE)
35 @Documented
36 public @interface Subcomponent {
37   /**
38    * A list of classes annotated with {@link Module} whose bindings are used to generate the
39    * subcomponent implementation.  Note that through the use of {@link Module#includes} the full set
40    * of modules used to implement the subcomponent may include more modules that just those listed
41    * here.
42    */
modules()43   Class<?>[] modules() default {};
44 
45   /**
46    * A builder for a subcomponent.
47    *
48    * <p>This follows all the rules of {@link Component.Builder}, except it must appear in classes
49    * annotated with {@link Subcomponent} instead of {@code Component}.
50    *
51    * <p>If a subcomponent defines a builder, its parent component(s) will have a binding for that
52    * builder type, allowing an instance or {@code Provider} of that builder to be injected or
53    * returned from a method on that component like any other binding.
54    */
55   @Retention(RUNTIME) // Allows runtimes to have specialized behavior interoperating with Dagger.
56   @Target(TYPE)
57   @Documented
58   @interface Builder {}
59 
60   /**
61    * A factory for a subcomponent.
62    *
63    * <p>This follows all the rules of {@link Component.Factory}, except it must appear in classes
64    * annotated with {@link Subcomponent} instead of {@code Component}.
65    *
66    * <p>If a subcomponent defines a factory, its parent component(s) will have a binding for that
67    * factory type, allowing an instance of that factory to be injected or returned from a method on
68    * that component like any other binding.
69    *
70    * @since 2.22
71    */
72   @Retention(RUNTIME) // Allows runtimes to have specialized behavior interoperating with Dagger.
73   @Target(TYPE)
74   @Documented
75   @interface Factory {}
76 }
77