1 /* 2 * Copyright (C) 2018 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.internal.codegen.componentgenerator; 18 19 import dagger.BindsInstance; 20 import dagger.Subcomponent; 21 import dagger.internal.codegen.binding.BindingGraph; 22 import dagger.internal.codegen.writing.ComponentBindingExpressions; 23 import dagger.internal.codegen.writing.ComponentImplementation; 24 import dagger.internal.codegen.writing.ComponentRequirementExpressions; 25 import dagger.internal.codegen.writing.ParentComponent; 26 import dagger.internal.codegen.writing.PerComponentImplementation; 27 import java.util.Optional; 28 29 /** 30 * A subcomponent that injects all objects that are responsible for creating a single {@link 31 * ComponentImplementation} instance. Each child {@link ComponentImplementation} will have its own 32 * instance of {@link CurrentImplementationSubcomponent}. 33 */ 34 @Subcomponent 35 @PerComponentImplementation 36 // This only needs to be public because the type is referenced by generated component. 37 public interface CurrentImplementationSubcomponent { componentImplementationBuilder()38 ComponentImplementationBuilder componentImplementationBuilder(); 39 40 /** Returns the builder for {@link CurrentImplementationSubcomponent}. */ 41 @Subcomponent.Builder 42 interface Builder { 43 @BindsInstance componentImplementation(ComponentImplementation componentImplementation)44 Builder componentImplementation(ComponentImplementation componentImplementation); 45 46 @BindsInstance bindingGraph(BindingGraph bindingGraph)47 Builder bindingGraph(BindingGraph bindingGraph); 48 49 @BindsInstance parentBuilder(@arentComponent Optional<ComponentImplementationBuilder> parentBuilder)50 Builder parentBuilder(@ParentComponent Optional<ComponentImplementationBuilder> parentBuilder); 51 52 @BindsInstance parentBindingExpressions( @arentComponent Optional<ComponentBindingExpressions> parentBindingExpressions)53 Builder parentBindingExpressions( 54 @ParentComponent Optional<ComponentBindingExpressions> parentBindingExpressions); 55 56 @BindsInstance parentRequirementExpressions( @arentComponent Optional<ComponentRequirementExpressions> parentRequirementExpressions)57 Builder parentRequirementExpressions( 58 @ParentComponent Optional<ComponentRequirementExpressions> parentRequirementExpressions); 59 build()60 CurrentImplementationSubcomponent build(); 61 } 62 } 63