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.google.common.collect.ImmutableMap;
019import com.sun.codemodel.JClass;
020import com.sun.codemodel.JClassAlreadyExistsException;
021import com.sun.codemodel.JDefinedClass;
022import com.sun.codemodel.JExpression;
023import org.androidtransfuse.Components;
024import org.androidtransfuse.adapter.PackageClass;
025import org.androidtransfuse.util.Repository;
026
027import javax.inject.Inject;
028import java.util.Map;
029
030/**
031 * @author John Ericksen
032 */
033public class ComponentsGenerator extends AbstractRepositoryGenerator<JDefinedClass> {
034
035    private static final PackageClass REPOSITORY_NAME = new PackageClass(Components.COMPONENTS_PACKAGE, Components.COMPONENTS_REPOSITORY_NAME);
036
037    @Inject
038    public ComponentsGenerator(ClassGenerationUtil generationUtil, UniqueVariableNamer namer) {
039        super(Repository.class, generationUtil, namer, REPOSITORY_NAME, Class.class);
040    }
041
042    @Override
043    protected Map<? extends JExpression, ? extends JExpression> generateMapping(JDefinedClass factoryRepositoryClass, JClass interfaceClass, JDefinedClass concreteType) throws JClassAlreadyExistsException {
044        return ImmutableMap.of(interfaceClass.dotclass(), concreteType.dotclass());
045    }
046}