/**
   * 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);
    }
  }
 /**
  * Generate Java interfaces for WADL resource types
  *
  * @throws com.sun.codemodel.JClassAlreadyExistsException if the interface to be generated already
  *     exists
  */
 protected void generateResourceTypeInterfaces() throws JClassAlreadyExistsException {
   for (String id : ifaceMap.keySet()) {
     ResourceTypeNode n = ifaceMap.get(id);
     JDefinedClass iface = jPkg._class(JMod.PUBLIC, n.getClassName(), ClassType.INTERFACE);
     n.setGeneratedInterface(iface);
     javaDoc.generateClassDoc(n, iface);
     ResourceClassGenerator rcGen =
         new ResourceClassGenerator(s2jModel, codeModel, jPkg, generatedPackages, javaDoc, iface);
     // generate Java methods for each resource method
     for (MethodNode m : n.getMethods()) {
       rcGen.generateMethodDecls(m, true);
     }
     // generate bean properties for matrix parameters
     for (Param p : n.getMatrixParams()) {
       rcGen.generateBeanProperty(iface, p, true);
     }
   }
 }