private JsonType buildType(DeclaredType declaredType, TypeElement element) {
      if (_typeRecursionGuard.contains(declaredType)) {
        return new JsonRecursiveObject(element.getSimpleName().toString());
      }

      JsonObject json = new JsonObject();
      buildTypeContents(json, element);
      return json; // we've already added to the cache; short-circuit to handle recursion
    }
    private void addFieldFromBeanMethod(JsonObject o, ExecutableElement executableElement) {
      if (!isJsonBeanGetter(executableElement)) {
        return;
      }

      TypeMirror type = executableElement.getReturnType();
      String methodName = executableElement.getSimpleName().toString();
      int trimLength = methodName.startsWith("is") ? 2 : 3;
      String beanName = methodName.substring(trimLength + 1, methodName.length());
      beanName = methodName.substring(trimLength, trimLength + 1).toLowerCase() + beanName;

      // loop over the element's generic types, and build a concrete list from the owning context
      List<DeclaredType> concreteTypes = new ArrayList();

      // replace variables with the current concrete manifestation
      if (type instanceof TypeVariable) {
        type = getDeclaredTypeForTypeVariable((TypeVariable) type);
        if (type == null) {
          return; // couldn't find a replacement -- must be a generics-capable type with no generics
                  // info
        }
      }

      String docComment = processingEnv.getElementUtils().getDocComment(executableElement);
      if (type instanceof DeclaredType) {
        TypeElement element = (TypeElement) ((DeclaredType) type).asElement();
        for (TypeParameterElement generic : element.getTypeParameters()) {
          concreteTypes.add(_typeArguments.get(generic.getSimpleName()));
        }
        Collection<DeclaredType> types = new HashSet<DeclaredType>(_typeRecursionGuard);
        types.add(_type);
        o.addField(beanName, newJsonType((DeclaredType) type, concreteTypes, types))
            .setCommentText(docComment);
      } else {
        o.addField(beanName, newJsonType(type)).setCommentText(docComment);
      }
    }
 private void addPackageName(Collection<String> processedPackageNames, Element e) {
   processedPackageNames.add(
       processingEnv.getElementUtils().getPackageOf(e).getQualifiedName().toString());
 }