/**
   * Adds list and view routes for the given entity. For instance, if you provide the entity name
   * "Reminder" you will get the routes:
   *
   * <pre>
   * /reminders
   * /reminders/{action}
   * /reminder/{reminder:Reminder}
   * /reminder/{reminder:Reminder}/{action}
   * </pre>
   *
   * @param entityName the entity name to route with
   * @param entityType the type of the enity
   * @param numericPKs if true, routes can assume numeric PK's and add some extra convenience routes
   * @param controllerClass the controller class
   */
  public void addDefaultRoutes(
      String entityName,
      String entityType,
      boolean numericPKs,
      Class<? extends ERXRouteController> controllerClass) {
    NSArray<ERXRoute> existingRoutes = routesForControllerClass(controllerClass);

    if (existingRoutes.isEmpty()) {
      addDeclaredRoutes(entityName, controllerClass, false);
    }

    String variableName =
        ERXStringUtilities.uncapitalize(
            entityName); // MS: We want this to always be Java variable-style "lowerFirstLetter"

    String externalName = ERXRestNameRegistry.registry().externalNameForInternalName(entityName);
    String singularExternalName = _entityNameFormat.formatEntityNamed(externalName, false);
    String pluralExternalName = _entityNameFormat.formatEntityNamed(externalName, true);

    if (_entityNameFormat.pluralRouteName()) {
      addRoute(
          new ERXRoute(
              entityName,
              "/" + pluralExternalName,
              ERXRoute.Method.Options,
              controllerClass,
              "options"));
    }
    addRoute(
        new ERXRoute(
            entityName,
            "/" + singularExternalName,
            ERXRoute.Method.Options,
            controllerClass,
            "options"));

    if (_entityNameFormat.pluralRouteName()) {
      addRoute(
          new ERXRoute(
              entityName, "/" + pluralExternalName, ERXRoute.Method.Head, controllerClass, "head"));
    }
    addRoute(
        new ERXRoute(
            entityName, "/" + singularExternalName, ERXRoute.Method.Head, controllerClass, "head"));

    if (_entityNameFormat.pluralRouteName()) {
      addRoute(
          new ERXRoute(
              entityName,
              "/" + pluralExternalName,
              ERXRoute.Method.Post,
              controllerClass,
              "create"));
    }
    addRoute(
        new ERXRoute(
            entityName,
            "/" + singularExternalName,
            ERXRoute.Method.Post,
            controllerClass,
            "create"));

    if (_entityNameFormat.pluralRouteName()) {
      addRoute(
          new ERXRoute(
              entityName, "/" + pluralExternalName, ERXRoute.Method.All, controllerClass, "index"));
    } else {
      addRoute(
          new ERXRoute(
              entityName,
              "/" + singularExternalName,
              ERXRoute.Method.All,
              controllerClass,
              "index"));
    }

    if (numericPKs) {
      // MS: this only works with numeric ids
      addRoute(
          new ERXRoute(
              entityName,
              "/" + singularExternalName + "/{action:identifier}",
              ERXRoute.Method.Get,
              controllerClass));
      if (_entityNameFormat.pluralRouteName()) {
        // MS: this only works with numeric ids
        addRoute(
            new ERXRoute(
                entityName,
                "/" + pluralExternalName + "/{action:identifier}",
                ERXRoute.Method.Get,
                controllerClass));
      }
    } else {
      addRoute(
          new ERXRoute(
              entityName,
              "/" + singularExternalName + "/new",
              ERXRoute.Method.All,
              controllerClass,
              "new"));
      if (_entityNameFormat.pluralRouteName()) {
        addRoute(
            new ERXRoute(
                entityName,
                "/" + pluralExternalName + "/new",
                ERXRoute.Method.All,
                controllerClass,
                "new"));
      }
    }

    if (_entityNameFormat.pluralRouteName()) {
      addRoute(
          new ERXRoute(
              entityName,
              "/" + pluralExternalName + "/{" + variableName + ":" + entityType + "}",
              ERXRoute.Method.Get,
              controllerClass,
              "show"));
    }
    addRoute(
        new ERXRoute(
            entityName,
            "/" + singularExternalName + "/{" + variableName + ":" + entityType + "}",
            ERXRoute.Method.Get,
            controllerClass,
            "show"));

    if (_entityNameFormat.pluralRouteName()) {
      addRoute(
          new ERXRoute(
              entityName,
              "/" + pluralExternalName + "/{" + variableName + ":" + entityType + "}",
              ERXRoute.Method.Put,
              controllerClass,
              "update"));
    }
    addRoute(
        new ERXRoute(
            entityName,
            "/" + singularExternalName + "/{" + variableName + ":" + entityType + "}",
            ERXRoute.Method.Put,
            controllerClass,
            "update"));

    if (_entityNameFormat.pluralRouteName()) {
      addRoute(
          new ERXRoute(
              entityName,
              "/" + pluralExternalName + "/{" + variableName + ":" + entityType + "}",
              ERXRoute.Method.Delete,
              controllerClass,
              "destroy"));
    }
    addRoute(
        new ERXRoute(
            entityName,
            "/" + singularExternalName + "/{" + variableName + ":" + entityType + "}",
            ERXRoute.Method.Delete,
            controllerClass,
            "destroy"));

    if (_entityNameFormat.pluralRouteName()) {
      addRoute(
          new ERXRoute(
              entityName,
              "/"
                  + pluralExternalName
                  + "/{"
                  + variableName
                  + ":"
                  + entityType
                  + "}/{action:identifier}",
              ERXRoute.Method.All,
              controllerClass));
    }
    addRoute(
        new ERXRoute(
            entityName,
            "/"
                + singularExternalName
                + "/{"
                + variableName
                + ":"
                + entityType
                + "}/{action:identifier}",
            ERXRoute.Method.All,
            controllerClass));
  }
 /**
  * Return the controller path name for an entity name based on the entity name format.
  *
  * @param entityName the entity name
  * @return the controller identifier part of the path (the "companies" part in "/companies/1000");
  */
 public String controllerPathForEntityNamed(String entityName) {
   return _entityNameFormat.formatEntityNamed(
       ERXRestNameRegistry.registry().externalNameForInternalName(entityName), true);
 }