• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2015 Google, Inc.
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 package dagger;
17 
18 import java.lang.annotation.Documented;
19 import java.lang.annotation.Retention;
20 import java.lang.annotation.Target;
21 
22 import static java.lang.annotation.ElementType.TYPE;
23 import static java.lang.annotation.RetentionPolicy.RUNTIME;
24 
25 /**
26  * A subcomponent that inherits the bindings from a parent {@link Component} or
27  * {@link Subcomponent}. The details of how to associate a subcomponent with a parent are described
28  * in the documentation for {@link Component}.
29  *
30  * @author Gregory Kick
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.  This follows all the rules of {@link Component.Builder}, except
47    * it must appear in classes annotated with {@link Subcomponent} instead of {@code Component}.
48    * Components can have methods that return a {@link Subcomponent.Builder}-annotated type,
49    * allowing the user to set modules on the subcomponent using their defined API.
50    */
51   @Target(TYPE)
52   @Documented
53   @interface Builder {}
54 }
55