// Path: src/com/kstenschke/shifter/utils/UtilsMap.java
// public class UtilsMap {
// 
//     public static int getSumOfValues(HashMap<String, Integer> map) {
//         int sum = 0;
//         for (int value : map.values()){
//             sum+= value;
//         }
//         return sum;
//     }
// 
//     public static String getKeyOfHighestValue(HashMap<String, Integer> map) {
//         int max    = 0;
//         String key = "";
// 
//         Iterator it = map.entrySet().iterator();
//         while (it.hasNext()) {
//             java.util.Map.Entry pairs = (java.util.Map.Entry) it.next();
//             int value = Integer.parseInt( pairs.getValue().toString());
//             if (value > max) {
//                 max = value;
//                 key = pairs.getKey().toString();
//             }
//             // Avoid ConcurrentModificationException
//             it.remove();
//         }
// 
//         return key;
//     }
// }


import com.kstenschke.shifter.utils.UtilsMap;
import org.apache.commons.lang.StringUtils;
import org.jetbrains.annotations.NotNull;
import java.util.HashMap;
            || value.endsWith(UNIT_IN) || value.endsWith(UNIT_MM)
            || value.endsWith(UNIT_PC) || value.endsWith(UNIT_PT) || value.endsWith(UNIT_PX)
            || value.endsWith(UNIT_VH) || value.endsWith(UNIT_VW)
        ) {
            return value.substring(value.length() - 2);
        }

        return "";
    }

    /**
     * @param  stylesheet   CSS content
     * @return String       most prominently used unit of given stylesheet, 'px' if none used yet
     */
    public static String determineMostProminentUnit(String stylesheet) {
        HashMap<String, Integer> map = new HashMap<>();

        map.put(UNIT_CM,   StringUtils.countMatches(stylesheet,UNIT_CM + ";"));
        map.put(UNIT_EM,   StringUtils.countMatches(stylesheet,UNIT_EM + ";"));
        map.put(UNIT_IN,   StringUtils.countMatches(stylesheet,UNIT_IN + ";"));
        map.put(UNIT_MM,   StringUtils.countMatches(stylesheet,UNIT_MM + ";"));
        map.put(UNIT_PC,   StringUtils.countMatches(stylesheet,UNIT_PC + ";"));
        map.put(UNIT_PT,   StringUtils.countMatches(stylesheet,UNIT_PT + ";"));
        map.put(UNIT_PX,   StringUtils.countMatches(stylesheet,UNIT_PX + ";"));
        map.put(UNIT_REM,  StringUtils.countMatches(stylesheet,UNIT_REM + ";"));
        map.put(UNIT_VW,   StringUtils.countMatches(stylesheet,UNIT_VW + ";"));
        map.put(UNIT_VH,   StringUtils.countMatches(stylesheet,UNIT_VH + ";"));
        map.put(UNIT_VMIN, StringUtils.countMatches(stylesheet,UNIT_VMIN + ";"));
        map.put(UNIT_VMAX, StringUtils.countMatches(stylesheet,UNIT_VMAX + ";"));

// Path: src/com/kstenschke/shifter/utils/UtilsMap.java
// public class UtilsMap {
// 
//     public static int getSumOfValues(HashMap<String, Integer> map) {
//         int sum = 0;
//         for (int value : map.values()){
//             sum+= value;
//         }
//         return sum;
//     }
// 
//     public static String getKeyOfHighestValue(HashMap<String, Integer> map) {
//         int max    = 0;
//         String key = "";
// 
//         Iterator it = map.entrySet().iterator();
//         while (it.hasNext()) {
//             java.util.Map.Entry pairs = (java.util.Map.Entry) it.next();
//             int value = Integer.parseInt( pairs.getValue().toString());
//             if (value > max) {
//                 max = value;
//                 key = pairs.getKey().toString();
//             }
//             // Avoid ConcurrentModificationException
//             it.remove();
//         }
// 
//         return key;
//     }
// }


// Path: src/com/kstenschke/shifter/models/shiftable_types/CssUnit.java
import com.kstenschke.shifter.utils.UtilsMap;
import org.apache.commons.lang.StringUtils;
import org.jetbrains.annotations.NotNull;
import java.util.HashMap;

            || value.endsWith(UNIT_IN) || value.endsWith(UNIT_MM)
            || value.endsWith(UNIT_PC) || value.endsWith(UNIT_PT) || value.endsWith(UNIT_PX)
            || value.endsWith(UNIT_VH) || value.endsWith(UNIT_VW)
        ) {
            return value.substring(value.length() - 2);
        }

        return "";
    }

    /**
     * @param  stylesheet   CSS content
     * @return String       most prominently used unit of given stylesheet, 'px' if none used yet
     */
    public static String determineMostProminentUnit(String stylesheet) {
        HashMap<String, Integer> map = new HashMap<>();

        map.put(UNIT_CM,   StringUtils.countMatches(stylesheet,UNIT_CM + ";"));
        map.put(UNIT_EM,   StringUtils.countMatches(stylesheet,UNIT_EM + ";"));
        map.put(UNIT_IN,   StringUtils.countMatches(stylesheet,UNIT_IN + ";"));
        map.put(UNIT_MM,   StringUtils.countMatches(stylesheet,UNIT_MM + ";"));
        map.put(UNIT_PC,   StringUtils.countMatches(stylesheet,UNIT_PC + ";"));
        map.put(UNIT_PT,   StringUtils.countMatches(stylesheet,UNIT_PT + ";"));
        map.put(UNIT_PX,   StringUtils.countMatches(stylesheet,UNIT_PX + ";"));
        map.put(UNIT_REM,  StringUtils.countMatches(stylesheet,UNIT_REM + ";"));
        map.put(UNIT_VW,   StringUtils.countMatches(stylesheet,UNIT_VW + ";"));
        map.put(UNIT_VH,   StringUtils.countMatches(stylesheet,UNIT_VH + ";"));
        map.put(UNIT_VMIN, StringUtils.countMatches(stylesheet,UNIT_VMIN + ";"));
        map.put(UNIT_VMAX, StringUtils.countMatches(stylesheet,UNIT_VMAX + ";"));

        return UtilsMap.getSumOfValues(map) == 0 ? "px" : UtilsMap.getKeyOfHighestValue(map);