/*
 * Copyright 2017 Banco Bilbao Vizcaya Argentaria, S.A..
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.bbva.arq.devops.ae.mirrorgate.core.utils;

import java.util.HashMap;
import java.util.Map;

/**
 * Enumeration of applications platforms.
 */
public enum Platform {
    Android("Android"),
    IOS("IOS"),
    Windows("Windows"),
    WindowsPhone("Windows Phone"),
    Unknown("Unkown");

    private final String name;

    Platform(String name) {
        this.name = name;
    }

    public String getName() {
        return name;
    }

    private static final Map<String, Platform> MAPPING = new HashMap<>();

    static {
        for (Platform platform : values()) {
            MAPPING.put(platform.getName().toLowerCase(), platform);
        }
    }

    public static Platform fromString(String value) {
        String key = value.toLowerCase();
        return MAPPING.containsKey(key) ? MAPPING.get(key) : Unknown;
    }
}

@@ -914,16 +914,32 @@
 Unkown%22)
+,%0A    All(%22All%22)
 ;%0A%0A    p
@@ -1377,16 +1377,34 @@
 ng key =
+ (value != null) ?
  value.t
@@ -1415,16 +1415,24 @@
 erCase()
+ : %22All%22
 ;%0A      

return All if metrics do not specify platform