001/** 002 * Copyright 2013 John Ericksen 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016package org.androidtransfuse.gen.variableBuilder; 017 018import org.androidtransfuse.adapter.ASTBase; 019import org.androidtransfuse.adapter.ASTType; 020import org.androidtransfuse.analysis.AnalysisContext; 021import org.androidtransfuse.analysis.Analyzer; 022import org.androidtransfuse.analysis.InjectionPointFactory; 023import org.androidtransfuse.model.InjectionNode; 024import org.androidtransfuse.model.InjectionSignature; 025 026import javax.inject.Inject; 027import javax.inject.Named; 028 029/** 030 * @author John Ericksen 031 */ 032public class DependentInjectionNodeBuilder implements InjectionNodeBuilder{ 033 034 private final ASTType dependency; 035 private final ASTType returnType; 036 private final DependentVariableBuilder variableBuilder; 037 private final InjectionPointFactory injectionPointFactory; 038 private final VariableInjectionBuilderFactory variableInjectionBuilderFactory; 039 private final Analyzer analyzer; 040 041 @Inject 042 public DependentInjectionNodeBuilder(/*@Assisted("dependency")*/ @Named("dependency") ASTType dependency, 043 /*@Assisted("returnType")*/ @Named("returnType") ASTType returnType, 044 /*@Assisted*/ DependentVariableBuilder variableBuilder, 045 InjectionPointFactory injectionPointFactory, 046 VariableInjectionBuilderFactory variableInjectionBuilderFactory, 047 Analyzer analyzer) { 048 this.dependency = dependency; 049 this.returnType = returnType; 050 this.variableBuilder = variableBuilder; 051 this.injectionPointFactory = injectionPointFactory; 052 this.variableInjectionBuilderFactory = variableInjectionBuilderFactory; 053 this.analyzer = analyzer; 054 } 055 056 @Override 057 public InjectionNode buildInjectionNode(ASTBase target, InjectionSignature signature, AnalysisContext context) { 058 InjectionNode injectionNode = analyzer.analyze(signature, context); 059 060 InjectionNode contextInjectionNode = injectionPointFactory.buildInjectionNode(dependency, context); 061 062 injectionNode.addAspect(VariableBuilder.class, variableInjectionBuilderFactory.buildDependentVariableBuilderWrapper(contextInjectionNode, variableBuilder, returnType)); 063 064 return injectionNode; 065 } 066}