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;
017
018import com.sun.codemodel.JDefinedClass;
019import org.androidtransfuse.adapter.ASTType;
020import org.androidtransfuse.analysis.Analysis;
021import org.androidtransfuse.experiment.ComponentDescriptor;
022import org.androidtransfuse.transaction.TransactionWorker;
023
024import javax.inject.Inject;
025import javax.inject.Provider;
026
027/**
028 * @author John Ericksen
029 */
030public class AnalysisGenerationFactory {
031
032    @Inject
033    private Provider<org.androidtransfuse.experiment.ComponentGenerator> componentGeneratorProvider;
034
035    public Provider<TransactionWorker<Provider<ASTType>, JDefinedClass>> buildAnalysisGenerationProvider(Provider<? extends Analysis<org.androidtransfuse.experiment.ComponentDescriptor>> analysis) {
036        return new AnalysisGenerationProvider(analysis, componentGeneratorProvider);
037    }
038
039    private static final class AnalysisGenerationProvider implements Provider<TransactionWorker<Provider<ASTType>, JDefinedClass>> {
040
041        private Provider<? extends Analysis<ComponentDescriptor>> analysis;
042        private Provider<org.androidtransfuse.experiment.ComponentGenerator> generator;
043
044        private AnalysisGenerationProvider(Provider<? extends Analysis<ComponentDescriptor>> analysis, Provider<org.androidtransfuse.experiment.ComponentGenerator> generator) {
045            this.analysis = analysis;
046            this.generator = generator;
047        }
048
049        @Override
050        public TransactionWorker<Provider<ASTType>, JDefinedClass> get() {
051            return new AnalysisGeneration(analysis, generator);
052        }
053    }
054}