code: private static Link resolve(final URL contextUrl, 
                                  final Link link) {
          if (link != null && link.isTemplated()) {
              final String msg = "Link must not be templated";
              LOG.error(msg);
              throw new IllegalStateException(msg);
          }
          if (link == null) {
              return self(contextUrl.toString());
          } else {
              return copyOf(link).withHref(resolveHref(contextUrl, link.getHref()).toString()).build();
          }
      }
docs: Resolved a link using the URL of the current resource and returns it as an absolute Link.
  
  @param contextUrl the URL of the current context
  @param link optional link to follow
  @return absolute Link
  @throws IllegalArgumentException if resolving the link is failing