/**
  * Create a class that acts as a container for a hierarchy of static inner classes, one for each
  * resource described by the WADL file.
  *
  * @param root the resource element that corresponds to the root of the resource tree
  * @throws com.sun.codemodel.JClassAlreadyExistsException if, during code generation, the WADL
  *     processor attempts to create a duplicate class. This indicates a structural problem with
  *     the WADL file, e.g. duplicate peer resource entries.
  */
 protected void generateEndpointClass(ResourceNode root) throws JClassAlreadyExistsException {
   JDefinedClass impl = jPkg._class(JMod.PUBLIC, root.getClassName());
   javaDoc.generateClassDoc(root, impl);
   for (ResourceNode r : root.getChildResources()) {
     generateSubClass(impl, r);
   }
 }
  /**
   * Creates an inner static class that represents a resource and its methods. Recurses the tree of
   * child resources.
   *
   * @param parent the outer class for the static inner class being generated. This can either be
   *     the top level <code>Endpoint</code> class or a nested static inner class for a parent
   *     resource.
   * @param resource the WADL <code>resource</code> element being processed.
   * @throws com.sun.codemodel.JClassAlreadyExistsException if, during code generation, the WADL
   *     processor attempts to create a duplicate class. This indicates a structural problem with
   *     the WADL file, e.g. duplicate peer resource entries.
   */
  protected void generateSubClass(JDefinedClass parent, ResourceNode resource)
      throws JClassAlreadyExistsException {

    ResourceClassGenerator rcGen =
        new ResourceClassGenerator(s2jModel, codeModel, jPkg, generatedPackages, javaDoc, resource);
    JDefinedClass impl = rcGen.generateClass(parent);

    // generate Java methods for each resource method
    for (MethodNode m : resource.getMethods()) {
      rcGen.generateMethodDecls(m, false);
    }

    // generate sub classes for each child resource
    for (ResourceNode r : resource.getChildResources()) {
      generateSubClass(impl, r);
    }
  }