class EurekaMetadataParser {

    public List<ApiInfo> parseApiInfo(Map<String, String> eurekaMetadata) {
        Map<String, ApiInfo> apiInfo = new HashMap<>();

        eurekaMetadata.entrySet()
            .stream()
            .filter(metadata -> metadata.getKey().startsWith(API_INFO))
            .forEach(metadata -> {
                String[] keys = metadata.getKey().split("\\.");
                if (keys.length == 4) {
                    apiInfo.putIfAbsent(keys[2], new ApiInfo());
                    ApiInfo api = apiInfo.get(keys[2]);
                    switch (keys[3]) {
                        case API_INFO_API_ID:
                            api.setApiId(metadata.getValue());
                            break;
                        case API_INFO_GATEWAY_URL:
                            api.setGatewayUrl(metadata.getValue());
                            break;
                        case API_INFO_VERSION:
                            api.setVersion(metadata.getValue());
                            break;
                        case API_INFO_SWAGGER_URL:
                            api.setSwaggerUrl(metadata.getValue());
                            break;
                        case API_INFO_DOCUMENTATION_URL:
                            api.setDocumentationUrl(metadata.getValue());
                            break;
                        default:
                            apimlLog.log("org.zowe.apiml.common.apiInfoParsingError", metadata);
                            break;
                    }
                }
            });

        return new ArrayList<>(apiInfo.values());
    }

}