1 /* 2 * Copyright (C) 2016 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.producers; 18 19 import static java.lang.annotation.ElementType.TYPE; 20 import static java.lang.annotation.RetentionPolicy.RUNTIME; 21 22 import dagger.Component; 23 import dagger.Module; 24 import dagger.Subcomponent; 25 import java.lang.annotation.Documented; 26 import java.lang.annotation.Retention; 27 import java.lang.annotation.Target; 28 29 /** 30 * A subcomponent that inherits the bindings from a parent {@link Component}, {@link Subcomponent}, 31 * {@link ProductionComponent}, or {@link ProductionSubcomponent}. The details of how to associate a 32 * subcomponent with a parent are described in the documentation for {@link Component}. 33 * 34 * <p>The executor for a production subcomponent is supplied by binding 35 * <code>{@literal @}Production Executor</code>, similar to {@link ProductionComponent}. Note that 36 * this binding may be in an ancestor component. 37 * 38 * @since 2.1 39 */ 40 @Retention(RUNTIME) // Allows runtimes to have specialized behavior interoperating with Dagger. 41 @Target(TYPE) 42 @Documented 43 public @interface ProductionSubcomponent { 44 /** 45 * A list of classes annotated with {@link Module} or {@link ProducerModule} whose bindings are 46 * used to generate the subcomponent implementation. Note that through the use of 47 * {@link Module#includes} or {@link ProducerModule#includes} the full set of modules used to 48 * implement the subcomponent may include more modules that just those listed here. 49 */ modules()50 Class<?>[] modules() default {}; 51 52 /** 53 * A builder for a production subcomponent. 54 * 55 * <p>This follows all the rules of {@link Component.Builder}, except it must appear in classes 56 * annotated with {@link ProductionSubcomponent} instead of {@code Component}. 57 * 58 * <p>If a subcomponent defines a builder, its parent component(s) will have a binding for that 59 * builder type, allowing an instance or {@code Provider} of that builder to be injected or 60 * returned from a method on that component like any other binding. 61 */ 62 @Retention(RUNTIME) // Allows runtimes to have specialized behavior interoperating with Dagger. 63 @Target(TYPE) 64 @Documented 65 @interface Builder {} 66 67 /** 68 * A factory for a production subcomponent. 69 * 70 * <p>This follows all the rules of {@link Component.Factory}, except it must appear in classes 71 * annotated with {@link ProductionSubcomponent} instead of {@code Component}. 72 * 73 * <p>If a subcomponent defines a factory, its parent component(s) will have a binding for that 74 * factory type, allowing an instance that factory to be injected or returned from a method on 75 * that component like any other binding. 76 * 77 * @since 2.22 78 */ 79 @Retention(RUNTIME) // Allows runtimes to have specialized behavior interoperating with Dagger. 80 @Target(TYPE) 81 @Documented 82 @interface Factory {} 83 } 84