class ServiceInstanceMetadataUtils {

    public static String getMetadataServiceParameter(List<URL> urls) {

        Map<String, Map<String, String>> params = new HashMap<>();

        urls.stream()
                // remove APPLICATION_KEY because service name must be present
                .map(url -> url.removeParameter(APPLICATION_KEY))
                // remove GROUP_KEY, always uses application name.
                .map(url -> url.removeParameter(GROUP_KEY))
                // remove DEPRECATED_KEY because it's always false
                .map(url -> url.removeParameter(DEPRECATED_KEY))
                // remove TIMESTAMP_KEY because it's nonsense
                .map(url -> url.removeParameter(TIMESTAMP_KEY))
                .forEach(url -> {
                    String protocol = url.getProtocol();
                    params.put(protocol, getParams(url));
                });

        if (params.isEmpty()) {
            return null;
        }

        return JSON.toJSONString(params);
    }

}