/**
  * Construct.
  *
  * @param refHandler
  */
 public ResourceReferenceLogData(ResourceReferenceRequestHandler refHandler) {
   super(
       refHandler.getResourceReference().getName(),
       refHandler.getLocale(),
       refHandler.getStyle(),
       refHandler.getVariation());
   resourceReferenceClass = refHandler.getResourceReference().getClass();
   scope = refHandler.getResourceReference().getScope();
   pageParameters = refHandler.getPageParameters();
 }
  @Override
  public Url mapHandler(IRequestHandler requestHandler) {
    if (!(requestHandler instanceof ResourceReferenceRequestHandler)) {
      return null;
    }

    ResourceReferenceRequestHandler handler = (ResourceReferenceRequestHandler) requestHandler;

    // see if request handler addresses the resource reference we serve
    if (!handlesRequest(handler)) {
      return null;
    }

    Url url = new Url();

    // add mount path segments
    for (String segment : mountSegments) {
      url.getSegments().add(segment);
    }

    // replace placeholder parameters
    PageParameters parameters = new PageParameters(handler.getPageParameters());

    for (int index = 0; index < mountSegments.length; ++index) {
      String placeholder = getPlaceholder(mountSegments[index]);

      if (placeholder != null) {
        url.getSegments().set(index, parameters.get(placeholder).toString(""));
        parameters.remove(placeholder);
      }
    }

    // add caching information
    addCachingDecoration(url, parameters);

    // create url
    return encodePageParameters(url, parameters, parametersEncoder);
  }