Beispiel #1
0
  private void parseMethod(Api api, ExecutableElement executableElement) throws IOException {

    Element actionElement =
        generator
            .getProcessingEnvironment()
            .getElementUtils()
            .getTypeElement(ApiMethodDoc.class.getName());
    TypeMirror apiMethodDocType = actionElement.asType();

    for (AnnotationMirror am : executableElement.getAnnotationMirrors()) {
      if (am.getAnnotationType().equals(apiMethodDocType)) {
        api.apiMethodDoc = Maps.newHashMap();
        for (Map.Entry<? extends ExecutableElement, ? extends AnnotationValue> ee :
            am.getElementValues().entrySet()) {
          api.apiMethodDoc.put(ee.getKey().getSimpleName().toString(), ee.getValue());
        }
        break;
      }
    }

    // generator.log("apiMethodDoc: " + api.apiMethodDoc);

    if (null == api.apiMethodDoc) {
      generator.log("Method miss @ApiMethodDoc. " + executableElement);
      return;
    }

    api.methodName = executableElement.getSimpleName().toString();
    api.methodMapping = executableElement.getAnnotation(RequestMapping.class);
    api.parameters = Lists.newArrayList();

    for (VariableElement var : executableElement.getParameters()) {
      api.parameters.add(var);
    }
  }