public static Map map(Object... keyvals) {
        if (keyvals == null) {
            return new HashMap();
        } else if (keyvals.length % 2 != 0) {
            throw new IllegalArgumentException("Map must have an even number of elements");
        } else {
            Map m = new HashMap(keyvals.length / 2);
            for (int i = 0; i < keyvals.length; i += 2) {
                m.put(keyvals[i], keyvals[i + 1]);
            }
            return Collections.unmodifiableMap(m);
        }
    }