package autodagger.compiler.utils;

import com.google.auto.common.MoreElements;
import com.squareup.javapoet.ClassName;

import org.apache.commons.lang3.StringUtils;

import javax.lang.model.element.Element;

/**
 * @author Lukasz Piliszczuk - lukasz.pili@gmail.com
 */
public class AutoComponentClassNameUtil {

    public static ClassName getComponentClassName(Element element) {
        String pkg = MoreElements.getPackage(element).getQualifiedName().toString();
        String name = element.getSimpleName().toString();

        if (!StringUtils.endsWith(name, "Component")) {
            name = name + "Component";
        }

        return ClassName.get(pkg, name);
    }
}

@@ -519,16 +519,362 @@
 ing();%0A%0A
+        return ClassName.get(pkg, getComponentSimpleName(name));%0A    %7D%0A%0A    public static ClassName getComponentClassName(ClassName elementClassName) %7B%0A        return ClassName.get(elementClassName.packageName(), getComponentSimpleName(elementClassName.simpleName()));%0A    %7D%0A%0A    public static String getComponentSimpleName(String elementName) %7B%0A
         
@@ -899,17 +899,24 @@
 ndsWith(
-n
+elementN
 ame, %22Co
@@ -944,16 +944,23 @@
     
-name = n
+return elementN
 ame 
@@ -1004,32 +1004,19 @@
 urn 
-ClassName.get(pkg, n
+elementN
 ame
-)
 ;%0A  

Add utils methods.