Exemplo n.º 1
0
    private void buildTypeContents(JsonObject o, TypeElement element) {
      if ("org.springframework.web.servlet.ModelAndView"
          .equals(element.getQualifiedName().toString())) {
        return;
      }
      if (element.getSuperclass().getKind() != TypeKind.NONE) {
        // an interface's superclass is TypeKind.NONE

        DeclaredType sup = (DeclaredType) element.getSuperclass();
        if (!isJsonPrimitive(sup)) {
          buildTypeContents(o, (TypeElement) sup.asElement());
        }
      }

      for (Element e : element.getEnclosedElements()) {
        if (e instanceof ExecutableElement) {
          addFieldFromBeanMethod(o, (ExecutableElement) e);
        }
      }
    }
Exemplo n.º 2
0
    private boolean isInstanceOf(TypeMirror typeMirror, Class type) {
      if (!(typeMirror instanceof DeclaredType)) {
        return false;
      }

      if (typeMirror.toString().startsWith(type.getName())) {
        return true;
      }

      DeclaredType declaredType = (DeclaredType) typeMirror;
      TypeElement typeElement = (TypeElement) declaredType.asElement();
      for (TypeMirror iface : typeElement.getInterfaces()) {
        if (isInstanceOf(iface, type)) {
          return true;
        }
      }
      return isInstanceOf(typeElement.getSuperclass(), type);
    }
Exemplo n.º 3
0
 private void checkSupertype(TypeElement te, String expect) {
   System.err.println("check supertype: " + te + " -- " + expect);
   String found = asString(te.getSuperclass());
   checkEqual("supertype", te, found, expect);
 }