use of io.crnk.core.repository.LinksRepositoryV2 in project crnk-framework by crnk-project.
the class ResponseRepositoryAdapter method doGetLinksInformation.
@SuppressWarnings({ "unchecked", "rawtypes" })
private LinksInformation doGetLinksInformation(Object repository, Iterable<?> resources, RepositoryRequestSpec requestSpec) {
if (resources instanceof ResourceList) {
ResourceList<?> resourceList = (ResourceList<?>) resources;
boolean createLinksInformation = resourceList instanceof DefaultResourceList;
LinksInformation newLinksInfo = enrichLinksInformation(resourceList.getLinks(), resources, requestSpec);
if (createLinksInformation) {
((DefaultResourceList) resources).setLinks(newLinksInfo);
}
return resourceList.getLinks();
}
LinksInformation linksInformation = null;
if (repository instanceof AnnotatedRepositoryAdapter) {
if (((AnnotatedRepositoryAdapter) repository).linksRepositoryAvailable()) {
linksInformation = ((LinksRepository) repository).getLinksInformation(resources, requestSpec.getQueryParams());
}
} else if (repository instanceof LinksRepositoryV2) {
linksInformation = ((LinksRepositoryV2) repository).getLinksInformation(resources, requestSpec.getResponseQuerySpec());
} else if (repository instanceof LinksRepository) {
linksInformation = ((LinksRepository) repository).getLinksInformation(resources, requestSpec.getQueryParams());
}
// everything deprecated anyway
return enrichLinksInformation(linksInformation, resources, requestSpec);
}
Aggregations