* @param methodElement Method to look for parameters
* @param parent The parent xml element to tack the results on
*/
private void processParams(Document doc, ExecutableElement methodElement, Element parent) {
for (VariableElement paramElement : methodElement.getParameters()) {
TypeMirror t = paramElement.asType();
if (skipParamType(t))
continue;
Element element = doc.createElement("param");
parent.appendChild(element);
// determine name
String name;
String paramType= BODY_INDICATOR;
PathParam pp = paramElement.getAnnotation(PathParam.class);
QueryParam qp = paramElement.getAnnotation(QueryParam.class);
ApiParam ap = paramElement.getAnnotation(ApiParam.class);
if (pp != null) {
name = pp.value();
paramType="Path";
}
else if (qp!=null) {
name = qp.value();
paramType="Query";
}
else if (ap!=null)
name = ap.name();
else {
Name nameElement = paramElement.getSimpleName();
name = nameElement.toString();
}
element.setAttribute("name", name);
element.setAttribute("paramType",paramType);
ApiParam apiParam = paramElement.getAnnotation(ApiParam.class);
if (apiParam!=null) {
String description = apiParam.value();
setOptionalAttribute(element, "description", description);
String required = String.valueOf(apiParam.required());
if (pp!=null || paramType.equals(BODY_INDICATOR)) // PathParams are always required
required="true";
setOptionalAttribute(element, "required", required, "false");
String allowedValues = apiParam.allowableValues();
setOptionalAttribute(element, "allowableValues", allowedValues, "all");
}
String defaultValue;
DefaultValue dva = paramElement.getAnnotation(DefaultValue.class);
if (dva!=null)
defaultValue = dva.value();
else if (ap!=null)
defaultValue = ap.defaultValue();
else
defaultValue = "-none-";
if (defaultValue!=null)
element.setAttribute("defaultValue",defaultValue);
String typeString = t.toString();
constructTypeNameAndAssign(element, typeString, "type");
}
}