this.request = request;
}
@Override @SuppressWarnings("deprecation") // For URL encoder.
public String to(Class<?> pageClass, Map<String, String> parameters) {
At at = pageClass.getAnnotation(At.class);
String uriTemplate;
if (at == null) {
// Fall back to see if this class was registered some other way (i.e. at().show())
PageBook.Page page = pageBook.forClass(pageClass);
if (page == null)
throw new IllegalArgumentException("No such page class was registered (missing @At annotation?): "
+ pageClass.getName());
uriTemplate = page.getUri();
} else
uriTemplate = at.value();
// Contextualize this request if necessary.
if (uriTemplate.startsWith("/"))
uriTemplate = request.get().context() + uriTemplate;