コード例 #1
0
  /**
   * Extracts parameters from a method call and attaches these with the comments extracted from the
   * javadoc
   *
   * @param apiAction The Verb of the action containing these parametes
   * @param method The method to inspect
   * @param parameterComments The parameter comments associated with these parameters
   * @return A collection of parameters keyed by name
   */
  protected Map<String, RamlQueryParameter> extractQueryParameters(
      RamlActionType apiAction, Method method, Map<String, String> parameterComments) {
    // Since POST requests have a body we choose to keep all request data in one place as much as
    // possible
    if (apiAction.equals(RamlActionType.POST) || method.getParameterCount() == 0) {
      return Collections.emptyMap();
    }
    Map<String, RamlQueryParameter> queryParams = new LinkedHashMap<>();

    for (Parameter param : method.getParameters()) {
      if (isQueryParameter(
          param)) { // Lets skip resourceIds since these are going to be going in the URL
        RamlParamType simpleType = SchemaHelper.mapSimpleType(param.getType());

        if (simpleType == null) {
          queryParams.putAll(
              SchemaHelper.convertClassToQueryParameters(
                  param, javaDocs.getJavaDoc(param.getType())));
        } else {
          // Check if we have comments
          String paramComment = parameterComments.get(param.getName());
          queryParams.putAll(SchemaHelper.convertParameterToQueryParameter(param, paramComment));
        }
      }
    }
    return queryParams;
  }