Ejemplo n.º 1
0
  /**
   * the constructor.
   *
   * @param element
   * @category constructor
   */
  public ClassGenerateHelper(Element element) {
    classElement = element;

    g.setPackageName(getPackageName(element));
    g.setTarget(getSimpleName(element));

    TypeElement superclass = AptUtil.getSuperClassElement(element);
    if (superclass.getAnnotation(JsonModel.class) != null) {
      g.setTargetBase(AptUtil.getFullQualifiedName(superclass));
      g.setExistsBase(true);
    }

    g.setPostfix(postfix);
    g.setTreatUnknownKeyAsError(getTreatUnknownKeyAsError(element));
  }
Ejemplo n.º 2
0
 @Override
 public JsonElement visitEnum(DeclaredType t, Element el) {
   Types typeUtils = processingEnv.getTypeUtils();
   if (AptUtil.isInternalType(typeUtils, el.asType())) {
     // InternalなEnum
     TypeElement typeElement = AptUtil.getTypeElement(typeUtils, el);
     if (AptUtil.isPublic(typeElement)) {
       return genJsonElement(t, el, Kind.ENUM);
     } else {
       Log.e("Internal EnumType must use public & static.", el);
       encountError = true;
       return defaultAction(t, el);
     }
   } else {
     // InternalじゃないEnum
     return genJsonElement(t, el, Kind.ENUM);
   }
 }