code: protected UrlConfig getUrlConfigForTarget(Adaptable adaptable, Page targetPage) {
      Resource targetResource = null;
      if (targetPage != null) {
        targetResource = targetPage.adaptTo(Resource.class);
      }
      return getUrlConfigForTarget(adaptable, targetResource);
    }
docs: Get URL configuration for target page. If this is invalid or not available, get it from adaptable.
  @param adaptable Adaptable (request or resource)
  @param targetPage Target page (may be null)
  @return Url config (never null)