1 /* 2 * Copyright (C) 2017 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; 18 19 import com.google.auto.value.AutoValue; 20 import com.google.common.collect.ImmutableMap; 21 import com.squareup.javapoet.ClassName; 22 import com.squareup.javapoet.FieldSpec; 23 import com.squareup.javapoet.TypeSpec; 24 25 /** The implementation of a component creator type. */ 26 @AutoValue 27 abstract class ComponentCreatorImplementation { 28 29 /** Creates a new {@link ComponentCreatorImplementation}. */ create( TypeSpec spec, ClassName name, ImmutableMap<ComponentRequirement, FieldSpec> fields)30 static ComponentCreatorImplementation create( 31 TypeSpec spec, 32 ClassName name, 33 ImmutableMap<ComponentRequirement, FieldSpec> fields) { 34 return new AutoValue_ComponentCreatorImplementation(spec, name, fields); 35 } 36 37 /** The type spec for the creator implementation. */ spec()38 abstract TypeSpec spec(); 39 40 /** The name of the creator implementation class. */ name()41 abstract ClassName name(); 42 43 /** 44 * All fields that are present in this implementation or its supertype. 45 * 46 * <p>In the case of ahead-of-time subcomponents, not all fields will necessarily be passed to 47 * the component's constructor (because, for example, it turns out that a particular module that 48 * the creator can set is actually inherited from an ancestor module). 49 */ fields()50 abstract ImmutableMap<ComponentRequirement, FieldSpec> fields(); 51 } 52