use of com.sun.javadoc.AnnotationDesc.ElementValuePair in project jersey by jersey.
the class ResourceDoclet method addParamDocs.
private static void addParamDocs(final MethodDoc methodDoc, final MethodDocType methodDocType, final DocProcessor docProcessor) {
final Parameter[] parameters = methodDoc.parameters();
final ParamTag[] paramTags = methodDoc.paramTags();
/* only use both javadoc and reflection information when the number
* of params are the same
*/
if (parameters != null && paramTags != null && parameters.length == paramTags.length) {
for (int i = 0; i < parameters.length; i++) {
final Parameter parameter = parameters[i];
/* TODO: this only works if the params and tags are in the same
* order. If the param tags are mixed up, the comments for parameters
* will be wrong.
*/
final ParamTag paramTag = paramTags[i];
final ParamDocType paramDocType = new ParamDocType();
paramDocType.setParamName(paramTag.parameterName());
paramDocType.setCommentText(paramTag.parameterComment());
docProcessor.processParamTag(paramTag, parameter, paramDocType);
final AnnotationDesc[] annotations = parameter.annotations();
if (annotations != null) {
for (final AnnotationDesc annotationDesc : annotations) {
final AnnotationDocType annotationDocType = new AnnotationDocType();
final String typeName = annotationDesc.annotationType().qualifiedName();
annotationDocType.setAnnotationTypeName(typeName);
for (final ElementValuePair elementValuePair : annotationDesc.elementValues()) {
final NamedValueType namedValueType = new NamedValueType();
namedValueType.setName(elementValuePair.element().name());
namedValueType.setValue(elementValuePair.value().value().toString());
annotationDocType.getAttributeDocs().add(namedValueType);
}
paramDocType.getAnnotationDocs().add(annotationDocType);
}
}
methodDocType.getParamDocs().add(paramDocType);
}
}
}
use of com.sun.javadoc.AnnotationDesc.ElementValuePair in project RESTdoclet by IG-Group.
the class AnnotationUtils method elementValue.
/**
* Gets an element-value pair of an annotation an argument of a method is
* annotated with.
*
* @param param the argument to check for annotations.
* @param type the type of annotation to look for.
* @param elementName the name of the element in the annotation to look for.
* @return the value of the element in the annotation or <code>null</code>
* if the annotation is not found or the name of the element is not
* found.
*/
public static AnnotationValue elementValue(final Parameter param, final Class<?> type, final String elementName) {
AnnotationValue value = null;
final ElementValuePair[] pairs = elementValues(param, type);
for (final ElementValuePair pair : pairs) {
if (StringUtils.equals(elementName, pair.element().name())) {
value = pair.value();
break;
}
}
return value;
}
use of com.sun.javadoc.AnnotationDesc.ElementValuePair in project RESTdoclet by IG-Group.
the class AnnotationUtils method elementValue.
/**
* Gets an element-value pair of an annotation an element (class or method)
* is annotated with.
*
* @param element the element to check for annotations.
* @param type the type of annotation to look for.
* @param elementName the name of the element in the annotation to look for.
* @return the value of the element in the annotation or <code>null</code>
* if the annotation is not found or the name of the element is not
* found.
*/
public static AnnotationValue elementValue(final ProgramElementDoc element, final Class<?> type, final String elementName) {
AnnotationValue value = null;
final ElementValuePair[] pairs = elementValues(element, type);
for (ElementValuePair pair : pairs) {
if (StringUtils.equals(elementName, pair.element().name())) {
value = pair.value();
break;
}
}
return value;
}
Aggregations