package com.ryanharter.auto.value.parcel;

import javax.lang.model.element.TypeElement;
import javax.lang.model.type.TypeKind;
import javax.lang.model.type.TypeMirror;
import javax.lang.model.util.Elements;
import javax.lang.model.util.Types;

public final class TypeSimplifier {

  private TypeSimplifier() {
  }

  static boolean isClassOfType(Types typeUtils, TypeMirror type, TypeMirror cls) {
    return type != null && typeUtils.isAssignable(cls, type);
  }

  static TypeMirror typeFromClass(Types types, Elements elements, Class<?> cls) {
    if (cls == void.class) {
      return types.getNoType(TypeKind.VOID);
    } else if (cls.isPrimitive()) {
      String primitiveName = cls.getName().toUpperCase();
      TypeKind primitiveKind = TypeKind.valueOf(primitiveName);
      return types.getPrimitiveType(primitiveKind);
    } else if (cls.isArray()) {
      TypeMirror componentType = typeFromClass(types, elements, cls.getComponentType());
      return types.getArrayType(componentType);
    } else {
      TypeElement element = elements.getTypeElement(cls.getCanonicalName());
      if (element == null) {
        throw new IllegalArgumentException("Unknown type: " + cls.getCanonicalName());
      }
      return element.asType();
    }
  }

}

@@ -64,146 +64,23 @@
 del.
-element.TypeElement;%0Aimport javax.lang.model.type.TypeKind;%0Aimport javax.lang.model.type.TypeMirror;%0Aimport javax.lang.model.util.Elements
+type.TypeMirror
 ;%0Aim
@@ -118,15 +118,8 @@
 s;%0A%0A
-public 
 fina
@@ -143,16 +143,16 @@
 ifier %7B%0A
+
 %0A  priva
@@ -327,802 +327,10 @@
 e);%0A
+
   %7D%0A
-%0A  static TypeMirror typeFromClass(Types types, Elements elements, Class%3C?%3E cls) %7B%0A    if (cls == void.class) %7B%0A      return types.getNoType(TypeKind.VOID);%0A    %7D else if (cls.isPrimitive()) %7B%0A      String primitiveName = cls.getName().toUpperCase();%0A      TypeKind primitiveKind = TypeKind.valueOf(primitiveName);%0A      return types.getPrimitiveType(primitiveKind);%0A    %7D else if (cls.isArray()) %7B%0A      TypeMirror componentType = typeFromClass(types, elements, cls.getComponentType());%0A      return types.getArrayType(componentType);%0A    %7D else %7B%0A      TypeElement element = elements.getTypeElement(cls.getCanonicalName());%0A      if (element == null) %7B%0A        throw new IllegalArgumentException(%22Unknown type: %22 + cls.getCanonicalName());%0A      %7D%0A      return element.asType();%0A    %7D%0A  %7D%0A%0A
 %7D%0A

Remove unused code. Reduce util class visibility.