Here you can find the source of buildMap(Object key, Object value)
public static Map buildMap(Object key, Object value)
//package com.java2s; /*//from w w w .ja v a 2 s. c o m * Copyright 2012 The Solmix Project * * This is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as * published by the Free Software Foundation; either version 2.1 of * the License, or (at your option) any later version. * * This software is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * http://www.gnu.org/licenses/ * or see the FSF site: http://www.fsf.org. */ import java.util.HashMap; import java.util.Map; public class Main { public static Map buildMap(Object key, Object value) { return buildMap(key, value, null, null, null, null, null, null, null, null, null, null); } /** * @param key * @param value * @param key2 * @param value2 * @return */ public static Map buildMap(Object key, Object value, Object key2, Object value2) { return buildMap(key, value, key2, value2, null, null, null, null, null, null, null, null); } public static Map buildMap(Object key, Object value, Object key2, Object value2, Object key3, Object value3) { return buildMap(key, value, key2, value2, key3, value3, null, null, null, null, null, null); } public static Map buildMap(Object key, Object value, Object key2, Object value2, Object key3, Object value3, Object key4, Object value4) { return buildMap(key, value, key2, value2, key3, value3, key4, value4, null, null, null, null); } public static Map buildMap(Object key, Object value, Object key2, Object value2, Object key3, Object value3, Object key4, Object value4, Object key5, Object value5) { return buildMap(key, value, key2, value2, key3, value3, key4, value4, key5, value5, null, null); } public static Map buildMap(Object key, Object value, Object key2, Object value2, Object key3, Object value3, Object key4, Object value4, Object key5, Object value5, Object key6, Object value6) { Map result = new HashMap(); if (key != null) result.put(key, value); if (key2 != null) result.put(key2, value2); if (key3 != null) result.put(key3, value3); if (key4 != null) result.put(key4, value4); if (key5 != null) result.put(key5, value5); if (key6 != null) result.put(key6, value6); return result; } public static Map buildMap(Object key, Object value, Object key2, Object value2, Object key3, Object value3, Object key4, Object value4, Object key5, Object value5, Object key6, Object value6, Object key7, Object value7) { Map result = new HashMap(); if (key != null) result.put(key, value); if (key2 != null) result.put(key2, value2); if (key3 != null) result.put(key3, value3); if (key4 != null) result.put(key4, value4); if (key5 != null) result.put(key5, value5); if (key6 != null) result.put(key6, value6); if (key7 != null) result.put(key7, value7); return result; } }