// - note: at this point, the URI is transformed into plural (added `s`) in a hardcoded way - this
  // will change in the future
  final void addLinkHeaderOnPagedResourceRetrieval(
      final UriComponentsBuilder uriBuilder,
      final HttpServletResponse response,
      final Class clazz,
      final int page,
      final int totalPages,
      final int pageSize) {
    plural(uriBuilder, clazz);

    final StringBuilder linkHeader = new StringBuilder();
    if (hasNextPage(page, totalPages)) {
      final String uriForNextPage = constructNextPageUri(uriBuilder, page, pageSize);
      linkHeader.append(LinkUtil.createLinkHeader(uriForNextPage, LinkUtil.REL_NEXT));
    }
    if (hasPreviousPage(page)) {
      final String uriForPrevPage = constructPrevPageUri(uriBuilder, page, pageSize);
      appendCommaIfNecessary(linkHeader);
      linkHeader.append(LinkUtil.createLinkHeader(uriForPrevPage, LinkUtil.REL_PREV));
    }
    if (hasFirstPage(page)) {
      final String uriForFirstPage = constructFirstPageUri(uriBuilder, pageSize);
      appendCommaIfNecessary(linkHeader);
      linkHeader.append(LinkUtil.createLinkHeader(uriForFirstPage, LinkUtil.REL_FIRST));
    }
    if (hasLastPage(page, totalPages)) {
      final String uriForLastPage = constructLastPageUri(uriBuilder, totalPages, pageSize);
      appendCommaIfNecessary(linkHeader);
      linkHeader.append(LinkUtil.createLinkHeader(uriForLastPage, LinkUtil.REL_LAST));
    }

    if (linkHeader.length() > 0) {
      response.addHeader(HttpHeaders.LINK, linkHeader.toString());
    }
  }
  void addLinkHeaderOnSingleResourceRetrieval(final HttpServletResponse response) {
    final String requestURL =
        ServletUriComponentsBuilder.fromCurrentRequestUri().build().toUri().toASCIIString();
    final int positionOfLastSlash = requestURL.lastIndexOf("/");
    final String uriForResourceCreation = requestURL.substring(0, positionOfLastSlash);

    final String linkHeaderValue = LinkUtil.createLinkHeader(uriForResourceCreation, "collection");
    response.addHeader(HttpHeaders.LINK, linkHeaderValue);
  }