1 /* 2 * Copyright (C) 2015 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.processingstep; 18 19 import androidx.room.compiler.processing.XMessager; 20 import androidx.room.compiler.processing.XTypeElement; 21 import com.google.common.collect.ImmutableSet; 22 import com.squareup.javapoet.ClassName; 23 import dagger.internal.codegen.javapoet.TypeNames; 24 import javax.inject.Inject; 25 26 /** 27 * A processing step that is responsible for generating a special module for a {@link 28 * dagger.producers.ProductionComponent} or {@link dagger.producers.ProductionSubcomponent}. 29 */ 30 final class MonitoringModuleProcessingStep extends TypeCheckingProcessingStep<XTypeElement> { 31 private final XMessager messager; 32 private final MonitoringModuleGenerator monitoringModuleGenerator; 33 34 @Inject MonitoringModuleProcessingStep( XMessager messager, MonitoringModuleGenerator monitoringModuleGenerator)35 MonitoringModuleProcessingStep( 36 XMessager messager, MonitoringModuleGenerator monitoringModuleGenerator) { 37 this.messager = messager; 38 this.monitoringModuleGenerator = monitoringModuleGenerator; 39 } 40 41 @Override annotationClassNames()42 public ImmutableSet<ClassName> annotationClassNames() { 43 return ImmutableSet.of(TypeNames.PRODUCTION_COMPONENT, TypeNames.PRODUCTION_SUBCOMPONENT); 44 } 45 46 @Override process(XTypeElement productionComponent, ImmutableSet<ClassName> annotations)47 protected void process(XTypeElement productionComponent, ImmutableSet<ClassName> annotations) { 48 monitoringModuleGenerator.generate(productionComponent, messager); 49 } 50 } 51