List<Link> links = new ArrayList<Link>();
links.addAll(resource.getLinks());
Path basePath = new Path(id.expand().getHref());
LinkCollectingAssociationHandler associationHandler = new LinkCollectingAssociationHandler(entities, basePath,
associationLinks);
resource.getPersistentEntity().doWithAssociations(associationHandler);
for (Link link : associationHandler.getLinks()) {
if (resource.shouldRenderLink(link)) {
links.add(link);
}
}