package com.bluelinelabs.logansquare.processor.type.collection;

import com.bluelinelabs.logansquare.processor.TypeUtils;
import com.bluelinelabs.logansquare.processor.type.Type;
import com.squareup.javapoet.ClassName;

import javax.lang.model.type.TypeMirror;
import javax.lang.model.util.Elements;
import javax.lang.model.util.Types;

public abstract class CollectionType extends Type {

    public static CollectionType collectionTypeFor(TypeMirror typeMirror, TypeMirror genericClassTypeMirror, Elements elements, Types types) {
        CollectionType collectionType = null;
        switch (genericClassTypeMirror.toString()) {
            case "java.util.List":
            case "java.util.ArrayList":
                collectionType = new ArrayListCollectionType(ClassName.bestGuess(genericClassTypeMirror.toString()));
                break;
            case "java.util.LinkedList":
                collectionType = new LinkedListCollectionType(ClassName.bestGuess(genericClassTypeMirror.toString()));
                break;
            case "java.util.Map":
            case "java.util.HashMap":
                collectionType = new HashMapCollectionType(ClassName.bestGuess(genericClassTypeMirror.toString()));
                break;
            case "java.util.TreeMap":
                collectionType = new TreeMapCollectionType(ClassName.bestGuess(genericClassTypeMirror.toString()));
                break;
            case "java.util.LinkedHashMap":
                collectionType = new LinkedHashMapCollectionType(ClassName.bestGuess(genericClassTypeMirror.toString()));
                break;
            case "java.util.Set":
            case "java.util.HashSet":
                collectionType = new SetCollectionType(ClassName.bestGuess(genericClassTypeMirror.toString()));
                break;
            case "java.util.Queue":
            case "java.util.Deque":
            case "java.util.ArrayDeque":
                collectionType = new QueueCollectionType(ClassName.bestGuess(genericClassTypeMirror.toString()));
                break;
        }

        if (collectionType != null) {
            collectionType.addParameterTypes(TypeUtils.getParameterizedTypes(typeMirror), elements, types);
        }

        return collectionType;
    }

}

@@ -584,49 +584,138 @@
     
-switch (genericClassTypeMirror.toString()
+%0A        String typeMirrorInfo = genericClassTypeMirror.toString().replaceAll(%22%3C.*%3E%22, %22%22);%0A        %0A        switch (typeMirrorInfo
 ) %7B%0A
@@ -874,41 +874,22 @@
 ess(
-genericClassTypeMirror.toString()
+typeMirrorInfo
 ));%0A
@@ -1038,41 +1038,22 @@
 ess(
-genericClassTypeMirror.toString()
+typeMirrorInfo
 ));%0A
@@ -1230,41 +1230,22 @@
 ess(
-genericClassTypeMirror.toString()
+typeMirrorInfo
 ));%0A
@@ -1388,41 +1388,22 @@
 ess(
-genericClassTypeMirror.toString()
+typeMirrorInfo
 ));%0A
@@ -1558,41 +1558,22 @@
 ess(
-genericClassTypeMirror.toString()
+typeMirrorInfo
 ));%0A
@@ -1746,41 +1746,22 @@
 ess(
-genericClassTypeMirror.toString()
+typeMirrorInfo
 ));%0A
@@ -1977,41 +1977,22 @@
 ess(
-genericClassTypeMirror.toString()
+typeMirrorInfo
 ));%0A

Fix for the eclipse compiler.