Examples of AnnotationDesc


Examples of com.sun.javadoc.AnnotationDesc

    * @return the annotation the argument is annotated with or
    *         <code>null</code> if the annotation is not found.
    */
   public static AnnotationDesc annotation(final Parameter param,
                                           final Class<?> type) {
      AnnotationDesc result = null;
      for (final AnnotationDesc annotation : annotations(param)) {
         final String name = annotation.annotationType().qualifiedName();
         if (StringUtils.equals(type.getName(), name)) {
            result = annotation;
            break;
View Full Code Here

Examples of com.sun.javadoc.AnnotationDesc

    * @return the annotation the element is annotated with or <code>null</code>
    *         if the annotation is not found.
    */
   public static AnnotationDesc annotation(final ProgramElementDoc element,
                                           final Class<?> type) {
      AnnotationDesc result = null;
      for (final AnnotationDesc annotation : annotations(element)) {
         final String name = annotation.annotationType().qualifiedName();
         if (StringUtils.equals(type.getName(), name)) {
            result = annotation;
            break;
View Full Code Here

Examples of com.sun.javadoc.AnnotationDesc

    public AnnotationParser(Parameter parameter) {
        annotations = parameter.annotations();
    }

    public String getAnnotationValue(String qualifiedAnnotationType, String key) {
        AnnotationDesc annotation = getAnnotation(qualifiedAnnotationType);
        if (annotation == null) {
            return null;
        }
        for (AnnotationDesc.ElementValuePair evp : annotation.elementValues()) {
            if (evp.element().name().equals(key)) {
                return evp.value().value().toString();
            }
        }
        return null;
View Full Code Here

Examples of com.sun.javadoc.AnnotationDesc

    public boolean isAnnotatedBy(String qualifiedAnnotationType) {
        return getAnnotation(qualifiedAnnotationType) != null;
    }

    private AnnotationDesc getAnnotation(String qualifiedAnnotationType) {
        AnnotationDesc found = null;
        for (AnnotationDesc annotation : annotations) {
            try {
                if (annotation.annotationType().qualifiedTypeName().equals(qualifiedAnnotationType)) {
                    found = annotation;
                    break;
View Full Code Here

Examples of com.sun.javadoc.AnnotationDesc

  /**
   * Check an array of annotations
   */
  private void checkAnnotations(Doc doc, AnnotationDesc[] annotations) {
    for (int i=0; i < annotations.length; i++) {
      AnnotationDesc annotationDesc = annotations[i];
      boolean isDocumented = false;
      for (AnnotationDesc a : annotationDesc.annotationType().annotations()) {
        if (java.lang.annotation.Documented.class.getName().equals(a.annotationType().qualifiedName())) {
          isDocumented = true;
        }
      }
      checkReference(doc, annotations[i], isDocumented ? WARNING_ANNOTATION : WARNING_PRIVATE_ANNOTATION);
View Full Code Here

Examples of com.sun.javadoc.AnnotationDesc

    }
  }

  private void setupMethods() {
    for (Class<?> methodAnnotation : MethodAnnotations) {
      final AnnotationDesc annotation = Utils.findMethodAnnotation(declaringClass, method, methodAnnotation);
      if (annotation != null)
        methods.add(annotation);
    }
  }
View Full Code Here

Examples of com.sun.javadoc.AnnotationDesc

  private void setupParameters() {
    int i = -1;
    for (final Parameter parameter : method.parameters()) {
      i++;
      final AnnotationDesc pathParamAnnotation = Utils.findParameterAnnotation(declaringMethod, parameter, i, PathParam.class);
      if (pathParamAnnotation != null) {
        String name = (String) Utils.getAnnotationValue(pathParamAnnotation);
        pathParameters.add(new RealMethodParameter(parameter, i, pathParamAnnotation, MethodParameterType.Path, declaringMethod));
        continue;
      }
      final AnnotationDesc matrixParamAnnotation = Utils.findParameterAnnotation(declaringMethod, parameter, i, MatrixParam.class);
      if (matrixParamAnnotation != null) {
        String name = (String) Utils.getAnnotationValue(matrixParamAnnotation);
        matrixParameters.add(new RealMethodParameter(parameter, i, matrixParamAnnotation, MethodParameterType.Matrix, declaringMethod));
        continue;
      }
      final AnnotationDesc queryParamAnnotation = Utils.findParameterAnnotation(declaringMethod, parameter, i, QueryParam.class);
      if (queryParamAnnotation != null) {
        String name = (String) Utils.getAnnotationValue(queryParamAnnotation);
        queryParameters.add(new RealMethodParameter(parameter, i, queryParamAnnotation, MethodParameterType.Query, declaringMethod));
        continue;
      }
      final AnnotationDesc cookieParamAnnotation = Utils.findParameterAnnotation(declaringMethod, parameter, i, CookieParam.class);
      if (cookieParamAnnotation != null) {
        String name = (String) Utils.getAnnotationValue(cookieParamAnnotation);
        cookieParameters.add(new RealMethodParameter(parameter, i, cookieParamAnnotation, MethodParameterType.Cookie, declaringMethod));
        continue;
      }
      final AnnotationDesc formParamAnnotation = Utils.findParameterAnnotation(declaringMethod, parameter, i, FormParam.class);
      if (formParamAnnotation != null) {
        String name = (String) Utils.getAnnotationValue(formParamAnnotation);
        formParameters.add(new RealMethodParameter(parameter, i, formParamAnnotation, MethodParameterType.Form, declaringMethod));
        continue;
      }
      final AnnotationDesc headerParamAnnotation = Utils.findParameterAnnotation(declaringMethod, parameter, i, HeaderParam.class);
      if (headerParamAnnotation != null) {
        String name = (String) Utils.getAnnotationValue(headerParamAnnotation);
        headerParameters.add(new RealMethodParameter(parameter, i, headerParamAnnotation, MethodParameterType.Header, declaringMethod));
        continue;
      }
      if (formClass != null) {
        final AnnotationDesc formAnnotation = Utils.findParameterAnnotation(declaringMethod, parameter, i, formClass);
        if (formAnnotation != null) {
          walkFormParameter(parameter.type().asClassDoc());
          continue;
        }
      }
      final AnnotationDesc contextAnnotation = Utils.findParameterAnnotation(declaringMethod, parameter, i, Context.class);
      if (contextAnnotation == null) {
        this.inputParameter = new RealMethodParameter(parameter, i, null, MethodParameterType.Input, declaringMethod);
      }
    }
  }
View Full Code Here

Examples of com.sun.javadoc.AnnotationDesc

  }

  private void walkFormParameter(ClassDoc formDoc) {
    // walk all fields
    for (FieldDoc field : formDoc.fields(false)) {
      final AnnotationDesc pathParamAnnotation = Utils.findAnnotation(field, PathParam.class);
      if (pathParamAnnotation != null) {
        String name = (String) Utils.getAnnotationValue(pathParamAnnotation);
        pathParameters.add(new FormFieldParameter(field, pathParamAnnotation, MethodParameterType.Path));
        continue;
      }
      final AnnotationDesc matrixParamAnnotation = Utils.findAnnotation(field, MatrixParam.class);
      if (matrixParamAnnotation != null) {
        matrixParameters.add(new FormFieldParameter(field, matrixParamAnnotation, MethodParameterType.Matrix));
        continue;
      }
      final AnnotationDesc queryParamAnnotation = Utils.findAnnotation(field, QueryParam.class);
      if (queryParamAnnotation != null) {
        String name = (String) Utils.getAnnotationValue(queryParamAnnotation);
        queryParameters.add(new FormFieldParameter(field, queryParamAnnotation, MethodParameterType.Query));
        continue;
      }
      final AnnotationDesc headerParamAnnotation = Utils.findAnnotation(field, HeaderParam.class);
      if (headerParamAnnotation != null) {
        String name = (String) Utils.getAnnotationValue(headerParamAnnotation);
        headerParameters.add(new FormFieldParameter(field, headerParamAnnotation, MethodParameterType.Header));
        continue;
      }
      final AnnotationDesc cookieParamAnnotation = Utils.findAnnotation(field, CookieParam.class);
      if (cookieParamAnnotation != null) {
        String name = (String) Utils.getAnnotationValue(cookieParamAnnotation);
        cookieParameters.add(new FormFieldParameter(field, cookieParamAnnotation, MethodParameterType.Cookie));
        continue;
      }
      final AnnotationDesc formParamAnnotation = Utils.findAnnotation(field, FormParam.class);
      if (formParamAnnotation != null) {
        formParameters.add(new FormFieldParameter(field, formParamAnnotation, MethodParameterType.Form));
        continue;
      }
      //Recurse into the embedded @Form field
      if(formClass != null) {
        final AnnotationDesc formAnnotation = Utils.findAnnotation(field, formClass);
        if(formAnnotation != null) {
            walkFormParameter(field.type().asClassDoc());
            continue;
        }
      }
     
      final AnnotationDesc contextAnnotation = Utils.findAnnotation(field, Context.class);
      if (contextAnnotation == null) {
        this.inputParameter = new FormFieldParameter(field, null, MethodParameterType.Input);
        continue;
      }
    }
    // and methods
    for (MethodDoc method : formDoc.methods(false)) {
      if (!method.returnType().qualifiedTypeName().equals("void") || method.parameters().length != 1 || !method.name().startsWith("set"))
        continue;
      Parameter parameter = method.parameters()[0];
      final AnnotationDesc pathParamAnnotation = Utils.findParameterAnnotation(method, parameter, 0, PathParam.class);
      if (pathParamAnnotation != null) {
        String name = (String) Utils.getAnnotationValue(pathParamAnnotation);
        pathParameters.add(new FormMethodParameter(method, pathParamAnnotation, MethodParameterType.Path));
        continue;
      }
      final AnnotationDesc matrixParamAnnotation = Utils.findParameterAnnotation(method, parameter, 0, MatrixParam.class);
      if (matrixParamAnnotation != null) {
        String name = (String) Utils.getAnnotationValue(matrixParamAnnotation);
        matrixParameters.add(new FormMethodParameter(method, matrixParamAnnotation, MethodParameterType.Matrix));
        continue;
      }
      final AnnotationDesc queryParamAnnotation = Utils.findParameterAnnotation(method, parameter, 0, QueryParam.class);
      if (queryParamAnnotation != null) {
        String name = (String) Utils.getAnnotationValue(queryParamAnnotation);
        queryParameters.add(new FormMethodParameter(method, queryParamAnnotation, MethodParameterType.Query));
        continue;
      }
      final AnnotationDesc headerParamAnnotation = Utils.findParameterAnnotation(method, parameter, 0, HeaderParam.class);
      if (headerParamAnnotation != null) {
        String name = (String) Utils.getAnnotationValue(headerParamAnnotation);
        headerParameters.add(new FormMethodParameter(method, headerParamAnnotation, MethodParameterType.Header));
        continue;
      }
      final AnnotationDesc cookieParamAnnotation = Utils.findParameterAnnotation(method, parameter, 0, CookieParam.class);
      if (cookieParamAnnotation != null) {
        String name = (String) Utils.getAnnotationValue(cookieParamAnnotation);
        cookieParameters.add(new FormMethodParameter(method, cookieParamAnnotation, MethodParameterType.Cookie));
        continue;
      }
      final AnnotationDesc formParamAnnotation = Utils.findParameterAnnotation(method, parameter, 0, FormParam.class);
      if (formParamAnnotation != null) {
        String name = (String) Utils.getAnnotationValue(formParamAnnotation);
        formParameters.add(new FormMethodParameter(method, formParamAnnotation, MethodParameterType.Form));
        continue;
      }
      // I'm not sure if @Form can be used on setter methods on an @Form field, but just in case...
      if(formClass != null) {
        //recurse into @Form parameters
        final AnnotationDesc formAnnotation = Utils.findParameterAnnotation(method, parameter, 0, formClass);
        if(formAnnotation != null) {
            walkFormParameter(parameter.type().asClassDoc());
            continue;
        }
      }
      final AnnotationDesc contextAnnotation = Utils.findParameterAnnotation(method, parameter, 0, Context.class);
      if (contextAnnotation == null) {
        this.inputParameter = new FormMethodParameter(method, null, MethodParameterType.Input);
      }
    }
  }
View Full Code Here

Examples of com.sun.javadoc.AnnotationDesc

      }
    }
  }

  private void setupPath() {
    final AnnotationDesc pathAnnotation = Utils.findMethodAnnotation(declaringClass, method, Path.class);
    final String rootPath = resource.getPath();
    if (pathAnnotation != null) {
      String path = (String) Utils.getAnnotationValue(pathAnnotation);
      path = Utils.removeFragmentRegexes(path, regexFragments);
      this.path = Utils.appendURLFragments(rootPath, path);
View Full Code Here

Examples of com.sun.javadoc.AnnotationDesc

    }
    return httpMethods;
  }

  public List<String> getProduces() {
    AnnotationDesc produces = getProducesAnnotation();
    if (produces == null) {
      return Collections.emptyList();
    } else {
      return Arrays.asList(Utils.getAnnotationValues(produces));
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.