class MapFunctions {

    public static <T, R> Map<T, R> asMap(Object... nameValuePairs) {

        if (nameValuePairs.length % 2 != 0) {
            throw new IllegalArgumentException("Should have an even number of names and values in list");
        }

        Map<T, R> map = new HashMap<>();

        for (int i = 0; i < nameValuePairs.length; i += 2) {
            T key = (T) nameValuePairs[i];
            R value = (R) nameValuePairs[i + 1];
            map.put(key, value);
        }

        return map;
    }

    private  MapFunctions();

}