class BerlinGroupLinksRewriter implements LinksRewriter {

    @Override
    public Map<String, HrefType> rewrite(Map<String, HrefType> links) {
        if (links == null || links.isEmpty()) {
            return links;
        }

        Map<String, HrefType> rewrittenLinks = new HashMap<>();

        for (Map.Entry<String, HrefType> linkEntry : links.entrySet()) {
            String linkName = linkEntry.getKey();
            HrefType linkFromAspsp = linkEntry.getValue();

            if (linkUnchangeable(linkName)) {
                rewrittenLinks.put(linkName, linkFromAspsp);
                continue;
            }

            Optional<String> linkTemplateOptional = linksTemplate.get(linkName);

            if (!linkTemplateOptional.isPresent()) {
                // business decision to leave unknown links untouched
                logger.warn("Links rewriting: unknown link [{}] - will be leaved unmapped", linkName);
                rewrittenLinks.put(linkName, linkFromAspsp);
                continue;
            }

            Optional<String> rewrittenLinksOptional
                = replacePlaceholdersWithValues(linkTemplateOptional.get(), linkFromAspsp.getHref());

            if (rewrittenLinksOptional.isPresent()) {
                String rewrittenLink = rewrittenLinksOptional.get();
                rewrittenLink = StringUri.copyQueryParams(linkFromAspsp.getHref(), rewrittenLink);
                HrefType link = new HrefType();
                link.setHref(rewrittenLink);
                rewrittenLinks.put(linkName, link);
            } else {
                // business decision to leave unknown links untouched
                logger.warn("Links rewriting: unknown format of the link [{}] - will be leaved unmapped. " +
                                "Custom rewriting should be provided to handle it", linkName);
                rewrittenLinks.put(linkName, linkFromAspsp);
            }
        }

        return rewrittenLinks;
    }

    public  BerlinGroupLinksRewriter(LinksTemplate linksTemplate,
                                    String host,
                                    String version);

}