use of com.sun.javadoc.AnnotationValue 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;
}
use of com.sun.javadoc.AnnotationValue in project RESTdoclet by IG-Group.
the class MethodBuilder method initRestParams.
/**
* Initialises the REST-parameters of this method.
*
* @param method method to initialise
* @param methodDoc the method's Java documentation object.
* @param baseUri the controller base uri
*/
private void initRestParams(Method method, final MethodDoc methodDoc, final String baseUri) {
LOG.debug(method.getName());
ArrayList<RestParameter> restParams = new ArrayList<RestParameter>();
for (NameValuePair pair : new RequestMappingParamsParser(elementValue(methodDoc, RequestMapping.class, "params")).parse()) {
final Predicate predicate = new ParameterNamePredicate(pair.getName());
if (!CollectionUtils.exists(method.getRequestParams(), predicate)) {
LOG.debug(pair.getName() + " - " + pair.getValue());
restParams.add(new RestParameter(pair));
}
}
AnnotationValue urlAnnotation = elementValue(methodDoc, RequestMapping.class, "value");
if (urlAnnotation != null) {
Boolean deprecatedMatch = false;
String[] methodUris = parseValueAnnotation(urlAnnotation);
String[] deprecatedURIs = DocTypeUtils.getDeprecatedURIs(methodDoc);
for (final String uri : methodUris) {
LOG.debug("uri:" + baseUri + uri);
boolean deprecated = false;
if (deprecatedURIs != null) {
for (final String deprecatedUri : deprecatedURIs) {
LOG.debug("deprecated:" + deprecatedUri);
if (StringUtils.equals(deprecatedUri, uri)) {
LOG.debug("=DEPRECATED");
deprecated = true;
deprecatedMatch = true;
break;
}
}
}
method.getUris().add(new Uri(baseUri + uri, deprecated));
}
if (deprecatedURIs != null && !deprecatedMatch) {
LOG.warn("Deprecated URI tag on method " + methodDoc.name() + " does not match any service URIs.");
}
}
method.setRestParams(restParams);
}
use of com.sun.javadoc.AnnotationValue in project RESTdoclet by IG-Group.
the class MethodBuilder method initConsumes.
private void initConsumes(Method method, final MethodDoc methodDoc) {
final AnnotationValue value = elementValue(methodDoc, RequestMapping.class, "consumes");
LOG.debug(method.getName());
if (value != null) {
method.setConsumes(value.toString().replace("\"", ""));
LOG.debug("CONSUMES " + method.getConsumes());
}
}
Aggregations