class JidInfoResponseTransformer {

    public static Map<String, List<RunnerInfo>> getHighStates(Map<String, List<Map<String, Object>>> map) {
        Map<String, Object> stringObjectMap;
        stringObjectMap = isOldSalt(map) ? (Map<String, Object>) map.get("return").get(0).get("data") : map.get("return").get(0);
        Map<String, List<RunnerInfo>> result = new HashMap<>();
        for (Entry<String, Object> stringObjectEntry : stringObjectMap.entrySet()) {
            if (stringObjectEntry.getValue() instanceof Map) {
                Map<String, Map<String, Object>> mapValue = (Map<String, Map<String, Object>>) stringObjectEntry.getValue();
                result.put(stringObjectEntry.getKey(), runnerInfoObjects(mapValue));
            } else if (stringObjectEntry.getValue() instanceof List) {
                List<String> listValue = (List<String>) stringObjectEntry.getValue();
                if (!listValue.isEmpty()) {
                    String errorMessage = listValue.stream().reduce((s, s2) -> s + "; " + s2).get();
                    throw new RuntimeException("Salt execution went wrong: " + errorMessage);
                }
            } else {
                throw new UnsupportedOperationException("Not supported Salt response: " + stringObjectEntry.getValue().getClass());
            }
        }

        return result;
    }

    private  JidInfoResponseTransformer();

}