1 /* 2 * Copyright (C) 2022 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.writing; 18 19 import com.squareup.javapoet.ClassName; 20 import com.squareup.javapoet.FieldSpec; 21 import com.squareup.javapoet.MethodSpec; 22 import com.squareup.javapoet.TypeSpec; 23 import dagger.internal.codegen.writing.ComponentImplementation.FieldSpecKind; 24 import dagger.internal.codegen.writing.ComponentImplementation.MethodSpecKind; 25 import dagger.internal.codegen.writing.ComponentImplementation.TypeSpecKind; 26 27 /** Represents the implementation of a generated class. */ 28 public interface GeneratedImplementation { 29 /** Returns the name of the component. */ name()30 ClassName name(); 31 32 /** Returns a new, unique method name for the component based on the given name. */ getUniqueClassName(String name)33 String getUniqueClassName(String name); 34 35 /** Adds the given field to the generated implementation. */ addField(FieldSpecKind fieldKind, FieldSpec fieldSpec)36 void addField(FieldSpecKind fieldKind, FieldSpec fieldSpec); 37 38 /** Adds the given method to the generated implementation. */ addMethod(MethodSpecKind methodKind, MethodSpec methodSpec)39 void addMethod(MethodSpecKind methodKind, MethodSpec methodSpec); 40 41 /** Adds the given type to the generated implementation. */ addType(TypeSpecKind typeKind, TypeSpec typeSpec)42 void addType(TypeSpecKind typeKind, TypeSpec typeSpec); 43 44 /** Returns the {@link TypeSpec} for this generated implementation. */ generate()45 public TypeSpec generate(); 46 } 47