Java Code Examples for com.sun.javadoc.MethodDoc#annotations()

The following examples show how to use com.sun.javadoc.MethodDoc#annotations() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PSPipelineDoc.java    From PrivacyStreams with Apache License 2.0 5 votes vote down vote up
public static PSPipelineDoc build(ClassDoc classDoc, MethodDoc methodDoc) {
    AnnotationDesc[] annotations = methodDoc.annotations();
    for (AnnotationDesc annotation : annotations) {
        AnnotationTypeDoc annotationType = annotation.annotationType();
        if (Consts.TRANSFORMATION_ANNOTATION.equals(annotationType.toString())) {
            return new PSPipelineDoc(classDoc, methodDoc, annotation, TYPE_TRANSFORMATION);
        }
        else if (Consts.ACTION_ANNOTATION.equals(annotationType.toString())) {
            return new PSPipelineDoc(classDoc, methodDoc, annotation, TYPE_ACTION);
        }
    }
    return null;
}
 
Example 2
Source File: Parser.java    From xml-doclet with Apache License 2.0 5 votes vote down vote up
protected Method parseMethod(MethodDoc methodDoc) {
	Method methodNode = objectFactory.createMethod();

	methodNode.setName(methodDoc.name());
	methodNode.setQualified(methodDoc.qualifiedName());
	String comment = methodDoc.commentText();
	if (comment.length() > 0) {
		methodNode.setComment(comment);
	}
	methodNode.setScope(parseScope(methodDoc));
	methodNode.setAbstract(methodDoc.isAbstract());
	methodNode.setIncluded(methodDoc.isIncluded());
	methodNode.setFinal(methodDoc.isFinal());
	methodNode.setNative(methodDoc.isNative());
	methodNode.setStatic(methodDoc.isStatic());
	methodNode.setSynchronized(methodDoc.isSynchronized());
	methodNode.setVarArgs(methodDoc.isVarArgs());
	methodNode.setSignature(methodDoc.signature());
	methodNode.setReturn(parseTypeInfo(methodDoc.returnType()));

	for (Parameter parameter : methodDoc.parameters()) {
		methodNode.getParameter().add(parseMethodParameter(parameter));
	}

	for (Type exceptionType : methodDoc.thrownExceptionTypes()) {
		methodNode.getException().add(parseTypeInfo(exceptionType));
	}

	for (AnnotationDesc annotationDesc : methodDoc.annotations()) {
		methodNode.getAnnotation().add(parseAnnotationDesc(annotationDesc, methodDoc.qualifiedName()));
	}

	for (Tag tag : methodDoc.tags()) {
		methodNode.getTag().add(parseTag(tag));
	}

	return methodNode;
}
 
Example 3
Source File: SwaggerPropertiesDoclet.java    From springfox-javadoc with Apache License 2.0 4 votes vote down vote up
private static void processMethod(
  Properties properties,
  MethodDoc methodDoc,
  String defaultRequestMethod,
  String pathRoot,
  boolean exceptionRef) {

    for (AnnotationDesc annotationDesc : methodDoc.annotations()) {
        String annotationType = annotationDesc.annotationType().toString();
        if (isMapping(annotationType)) {
            StringBuilder path = new StringBuilder(pathRoot);
            for (AnnotationDesc.ElementValuePair pair : annotationDesc.elementValues()) {
                if (VALUE.equals(pair.element().name()) || PATH.equals(pair.element().name())) {
                    appendPath(path, pair);
                    break;
                }
            }
            if (!path.substring(path.length() - 1).equals(".")) {
                path.append(".");
            }
            String requestMethod = getRequestMethod(annotationDesc, annotationType, defaultRequestMethod);
            if (requestMethod != null) {
                path.append(requestMethod);
                saveProperty(properties, path.toString() + ".notes", methodDoc.commentText());

                for (ParamTag paramTag : methodDoc.paramTags()) {
                    saveProperty(properties, path.toString() + ".param." + paramTag.parameterName(),
                      paramTag.parameterComment());
                }
                for (Tag tag : methodDoc.tags()) {
                    if (tag.name().equals(RETURN)) {
                        saveProperty(properties, path.toString() + ".return", tag.text());
                        break;
                    }
                }
                if (exceptionRef) {
                    processThrows(properties, methodDoc.throwsTags(), path);
                }
            }
        }
    }
}