methodBlock.finish();
}
private void generateUrl(BlockBuilder<?> methodBlock) {
JaxrsResourceMethodParameters params = resourceMethod.getParameters();
ContextualStatementBuilder pathValue = Stmt.loadLiteral(resourceMethod.getPath());
List<String> pathParams =
((UriBuilderImpl) UriBuilderImpl.fromTemplate(resourceMethod.getPath())).getPathParamNamesInDeclarationOrder();
int i = 0;
for (String pathParam : pathParams) {
pathValue = pathValue.invoke("replaceFirst", "\\{" + pathParam + "\\}",
marshal(params.getPathParameter(pathParam, i++)));
}
methodBlock.append(Stmt.declareVariable("url", StringBuilder.class,
Stmt.newObject(StringBuilder.class).withParameters(pathValue)));
ContextualStatementBuilder urlBuilder = null;
if (params.getQueryParameters() != null) {
urlBuilder = Stmt.loadVariable("url").invoke(APPEND, "?");
i = 0;
for (String queryParamName : params.getQueryParameters().keySet()) {
for (Parameter queryParam : params.getQueryParameters(queryParamName)) {
if (i++ > 0)
urlBuilder = urlBuilder.invoke(APPEND, "&");
urlBuilder = urlBuilder.invoke(APPEND, queryParamName);
urlBuilder = urlBuilder.invoke(APPEND, "=");
urlBuilder = urlBuilder.invoke(APPEND, marshal(queryParam));
}
}
}
// TODO MatrixParams