processor/src/main/java/com/hannesdorfmann/parcelableplease/processor/codegenerator/SupportedTypes.java
public static CodeGenInfo getCodeGenInfo(VariableElement element, Elements elements,
                                           Types types) {

    // Special classes, primitive, wrappers, etc.
    String typeKey = element.asType().toString();
    if (typeMap.get(typeKey) != null) {
      return new CodeGenInfo(typeMap.get(typeKey));
    }

    // Check if its a simple parcelable
    if (isOfType(element, "android.os.Parcelable", elements, types)) {
      return new CodeGenInfo(typeMap.get(TYPE_KEY_PARCELABLE));
    }

    // Lists
    if (isOfWildCardType(element, ArrayList.class.getName(), "android.os.Parcelable", elements,
        types)) {

      return new CodeGenInfo(typeMap.get(TYPE_KEY_PARCELABLE_ARRAYLIST),
          hasGenericsTypeArgumentOf(element, "android.os.Parcelable", elements, types));
    }

    if (isOfWildCardType(element, LinkedList.class.getName(), "android.os.Parcelable", elements,
        types)) {
      return new CodeGenInfo(typeMap.get(TYPE_KEY_PARCELABLE_LINKEDLIST),
          hasGenericsTypeArgumentOf(element, "android.os.Parcelable", elements, types));
    }

    if (isOfWildCardType(element, CopyOnWriteArrayList.class.getName(), "android.os.Parcelable",
        elements, types)) {
      return new CodeGenInfo(typeMap.get(TYPE_KEY_PARCELABLE_COPYONWRITEARRAYLIST),
          hasGenericsTypeArgumentOf(element, "android.os.Parcelable", elements, types));
    }

    if (isOfWildCardType(element, List.class.getName(), "android.os.Parcelable", elements, types)) {
      return new CodeGenInfo(typeMap.get(TYPE_KEY_PARCELABLE_LIST),
          hasGenericsTypeArgumentOf(element, "android.os.Parcelable", elements, types));
    }

    if (isOfWildCardType(element, List.class.getName(), String.class.getName(), elements, types)) {
      return new CodeGenInfo(typeMap.get(TYPE_KEY_STRING_LIST));
    }

    // Arrays
    if (element.asType().getKind() == TypeKind.ARRAY) {

      ArrayType arrayType = (ArrayType) element.asType();

      TypeMirror arrayOf = arrayType.getComponentType();

      if (arrayOf.getKind() == TypeKind.CHAR) {
        return new CodeGenInfo(typeMap.get(TYPE_KEY_CHAR_ARRAY));
      }

      if (arrayOf.getKind() == TypeKind.BOOLEAN) {
        return new CodeGenInfo(typeMap.get(TYPE_KEY_BOOL_ARRAY));
      }

      if (arrayOf.getKind() == TypeKind.BYTE) {
        return new CodeGenInfo(typeMap.get(TYPE_KEY_BYTE_ARRAY));
      }

      if (arrayOf.getKind() == TypeKind.DOUBLE) {
        return new CodeGenInfo(typeMap.get(TYPE_KEY_DOUBLE_ARRAY));
      }

      if (arrayOf.getKind() == TypeKind.FLOAT) {
        return new CodeGenInfo(typeMap.get(TYPE_KEY_FLOAT_ARRAY));
      }

      if (arrayOf.getKind() == TypeKind.INT) {
        return new CodeGenInfo(typeMap.get(TYPE_KEY_INT_ARRAY));
      }

      if (arrayOf.getKind() == TypeKind.LONG) {
        return new CodeGenInfo(typeMap.get(TYPE_KEY_LONG_ARRAY));
      }

      if (arrayOf.toString().equals(String.class.getName())) {
        return new CodeGenInfo(typeMap.get(TYPE_KEY_STRING_ARRAY));
      }

      if (isOfType(arrayOf, "android.os.Parcelable", elements, types)) {
        // It's an array of parcelable
        return new CodeGenInfo(typeMap.get(TYPE_KEY_PARCELABLE_ARRAY), arrayOf);
      }

      // Unsupported Array Type
      ProcessorMessage.error(element, "Unsuppored type %s as Array type for field %s. "
              + "You could write your own Serialization mechanism by using @%s ",
          element.asType().toString(), element.getSimpleName(), Bagger.class.getSimpleName());
    }


    // TODO SparseArray
    // if (isOfWildCardType(element, "android.util.SparseArray", "android.os.Parcelable", elements,
    //     types)) {
    //  return new CodeGenInfo(typeMap.get(TYPE_KEY_SPARSE_ARRAY),
    //      hasGenericsTypeArgumentOf(element, null, elements, types));
    // }


    // Serializable as last
    if (isOfType(element, "java.io.Serializable", elements, types)) {
      return new CodeGenInfo(typeMap.get(TYPE_KEY_SERIALIZABLE));
    }

    // Unsupported type
    ProcessorMessage.error(element, "Unsuppored type %s for field %s. "
            + "You could write your own Serialization mechanism by using @%s ",
        element.asType().toString(), element.getSimpleName(), Bagger.class.getSimpleName());

    return new CodeGenInfo(null);
  }
public static CodeGenInfo getCodeGenInfo(VariableElement element, Elements elements,
                                           Types types) {

    // Special classes, primitive, wrappers, etc.
    String typeKey = element.asType().toString();
    if (typeMap.get(typeKey) != null) {
      return new CodeGenInfo(typeMap.get(typeKey));
    }

    // Check if its a simple parcelable
    if (isOfType(element, "android.os.Parcelable", elements, types)) {
      return new CodeGenInfo(typeMap.get(TYPE_KEY_PARCELABLE));
    }

    // Lists
    if (isOfWildCardType(element, ArrayList.class.getName(), "android.os.Parcelable", elements,
        types)) {

      return new CodeGenInfo(typeMap.get(TYPE_KEY_PARCELABLE_ARRAYLIST),
          hasGenericsTypeArgumentOf(element, "android.os.Parcelable", elements, types));
    }

    if (isOfWildCardType(element, LinkedList.class.getName(), "android.os.Parcelable", elements,
        types)) {
      return new CodeGenInfo(typeMap.get(TYPE_KEY_PARCELABLE_LINKEDLIST),
          hasGenericsTypeArgumentOf(element, "android.os.Parcelable", elements, types));
    }

    if (isOfWildCardType(element, CopyOnWriteArrayList.class.getName(), "android.os.Parcelable",
        elements, types)) {
      return new CodeGenInfo(typeMap.get(TYPE_KEY_PARCELABLE_COPYONWRITEARRAYLIST),
          hasGenericsTypeArgumentOf(element, "android.os.Parcelable", elements, types));
    }

    if (isOfWildCardType(element, List.class.getName(), "android.os.Parcelable", elements, types)) {
      return new CodeGenInfo(typeMap.get(TYPE_KEY_PARCELABLE_LIST),
          hasGenericsTypeArgumentOf(element, "android.os.Parcelable", elements, types));
    }

    if (isOfWildCardType(element, List.class.getName(), String.class.getName(), elements, types)) {
      return new CodeGenInfo(typeMap.get(TYPE_KEY_STRING_LIST));
    }

    // Arrays
    if (element.asType().getKind() == TypeKind.ARRAY) {

      ArrayType arrayType = (ArrayType) element.asType();

      TypeMirror arrayOf = arrayType.getComponentType();

      if (arrayOf.getKind() == TypeKind.CHAR) {
        return new CodeGenInfo(typeMap.get(TYPE_KEY_CHAR_ARRAY));
      }

      if (arrayOf.getKind() == TypeKind.BOOLEAN) {
        return new CodeGenInfo(typeMap.get(TYPE_KEY_BOOL_ARRAY));
      }

      if (arrayOf.getKind() == TypeKind.BYTE) {
        return new CodeGenInfo(typeMap.get(TYPE_KEY_BYTE_ARRAY));
      }

      if (arrayOf.getKind() == TypeKind.DOUBLE) {
        return new CodeGenInfo(typeMap.get(TYPE_KEY_DOUBLE_ARRAY));
      }

      if (arrayOf.getKind() == TypeKind.FLOAT) {
        return new CodeGenInfo(typeMap.get(TYPE_KEY_FLOAT_ARRAY));
      }

      if (arrayOf.getKind() == TypeKind.INT) {
        return new CodeGenInfo(typeMap.get(TYPE_KEY_INT_ARRAY));
      }

      if (arrayOf.getKind() == TypeKind.LONG) {
        return new CodeGenInfo(typeMap.get(TYPE_KEY_LONG_ARRAY));
      }

      if (arrayOf.toString().equals(String.class.getName())) {
        return new CodeGenInfo(typeMap.get(TYPE_KEY_STRING_ARRAY));
      }

      if (isOfType(arrayOf, "android.os.Parcelable", elements, types)) {
        // It's an array of parcelable
        return new CodeGenInfo(typeMap.get(TYPE_KEY_PARCELABLE_ARRAY), arrayOf);
      }

      // Unsupported Array Type
      ProcessorMessage.error(element, "Unsuppored type %s as Array type for field %s. "
              + "You could write your own Serialization mechanism by using @%s ",
          element.asType().toString(), element.getSimpleName(), Bagger.class.getSimpleName());
    }


    // TODO SparseArray
    // if (isOfWildCardType(element, "android.util.SparseArray", "android.os.Parcelable", elements,
    //     types)) {
    //  return new CodeGenInfo(typeMap.get(TYPE_KEY_SPARSE_ARRAY),
    //      hasGenericsTypeArgumentOf(element, null, elements, types));
    // }


    // Serializable as last
    if (isOfType(element, "java.io.Serializable", elements, types)) {
      return new CodeGenInfo(typeMap.get(TYPE_KEY_SERIALIZABLE));
    }

    // Unsupported type
    ProcessorMessage.error(element, "Unsuppored type %s for field %s. "
            + "You could write your own Serialization mechanism by using @%s ",
        element.asType().toString(), element.getSimpleName(), Bagger.class.getSimpleName());

    return new CodeGenInfo(null);
  }
Collect information about the element and the corresponding code generator