}
public Link linkToPagedResource(Class<?> type, Pageable pageable) {
ResourceMetadata metadata = mappings.getMappingFor(type);
TemplateVariables variables = new TemplateVariables();
String href = linkFor(type).withSelfRel().getHref();
if (metadata.isPagingResource()) {
UriComponentsBuilder builder = UriComponentsBuilder.fromUriString(href);
if (pageable != null) {
resolver.enhance(builder, null, pageable);
}
href = builder.build().toString();
variables = variables.concat(resolver.getPaginationTemplateVariables(null, builder.build()));
}
ProjectionDefinitionConfiguration projectionConfiguration = config.projectionConfiguration();
if (projectionConfiguration.hasProjectionFor(type)) {
variables = variables.concat(new TemplateVariable(projectionConfiguration.getParameterName(), REQUEST_PARAM));
}
return variables.asList().isEmpty() ? linkFor(type).withRel(metadata.getRel()) : new Link(new UriTemplate(href,
variables), metadata.getRel());
}