/** * Override superclass to ensure that MultiMap instances are * correctly handled. * <p> * If you call this method with a normal map, each entry is * added using <code>put(Object,Object)</code>. * If you call this method with a multi map, each entry is * added using <code>putAll(Object,Collection)</code>. * * @param map the map to copy (either a normal or multi map) */ public void putAll(Map map) { if (map instanceof MultiMap) { for (Iterator it = map.entrySet().iterator(); it.hasNext();) { Map.Entry entry = (Map.Entry) it.next(); Collection coll = (Collection) entry.getValue(); putAll(entry.getKey(), coll); } } else { for (Iterator it = map.entrySet().iterator(); it.hasNext();) { Map.Entry entry = (Map.Entry) it.next(); put(entry.getKey(), entry.getValue()); } } }
/** * Override superclass to ensure that MultiMap instances are * correctly handled. * <p> * If you call this method with a normal map, each entry is * added using <code>put(Object,Object)</code>. * If you call this method with a multi map, each entry is * added using <code>putAll(Object,Collection)</code>. * * @param map the map to copy (either a normal or multi map) */ public void putAll(Map map) { if (map instanceof MultiMap) { for (Iterator it = map.entrySet().iterator(); it.hasNext();) { Map.Entry entry = (Map.Entry) it.next(); Collection coll = (Collection) entry.getValue(); putAll(entry.getKey(), coll); } } else { for (Iterator it = map.entrySet().iterator(); it.hasNext();) { Map.Entry entry = (Map.Entry) it.next(); put(entry.getKey(), entry.getValue()); } } }
public void testPut_ReturnValue() { MultiValueMap test = new MultiValueMap(); assertNotNull(test.put("key", "object1")); assertNotNull(test.put("key", "object2")); List coll = Arrays.asList(new String[]{"uno", "un"}); assertTrue(test.putAll("key", coll)); assertFalse(test.putAll("key", new ArrayList())); }
public void testPutAll_Map2() { Map original = new HashMap(); original.put("keyX", "object1"); original.put("keyY", "object2"); MultiValueMap test = new MultiValueMap(); test.put("keyA", "objectA"); test.put("keyX", "object0"); test.putAll(original); assertEquals(3, test.size()); assertEquals(4, test.totalSize()); assertEquals(1, test.getCollection("keyA").size()); assertEquals(2, test.getCollection("keyX").size()); assertEquals(1, test.getCollection("keyY").size()); assertEquals(true, test.containsValue("objectA")); assertEquals(true, test.containsValue("object0")); assertEquals(true, test.containsValue("object1")); assertEquals(true, test.containsValue("object2")); }
public void testPutAll_KeyCollection() { MultiValueMap map = new MultiValueMap(); Collection coll = Arrays.asList(new Object[] {"X", "Y", "Z"}); assertEquals(true, map.putAll("A", coll)); assertEquals(3, map.size("A")); assertEquals(true, map.containsValue("A", "X")); assertEquals(true, map.containsValue("A", "Y")); assertEquals(true, map.containsValue("A", "Z")); assertEquals(false, map.putAll("A", null)); assertEquals(3, map.size("A")); assertEquals(true, map.containsValue("A", "X")); assertEquals(true, map.containsValue("A", "Y")); assertEquals(true, map.containsValue("A", "Z")); assertEquals(false, map.putAll("A", new ArrayList())); assertEquals(3, map.size("A")); assertEquals(true, map.containsValue("A", "X")); assertEquals(true, map.containsValue("A", "Y")); assertEquals(true, map.containsValue("A", "Z")); coll = Arrays.asList(new Object[] {"M"}); assertEquals(true, map.putAll("A", coll)); assertEquals(4, map.size("A")); assertEquals(true, map.containsValue("A", "X")); assertEquals(true, map.containsValue("A", "Y")); assertEquals(true, map.containsValue("A", "Z")); assertEquals(true, map.containsValue("A", "M")); }
public void testPutAll_Map1() { MultiMap original = new MultiValueMap(); original.put("key", "object1"); original.put("key", "object2"); MultiValueMap test = new MultiValueMap(); test.put("keyA", "objectA"); test.put("key", "object0"); test.putAll(original); assertEquals(2, test.size()); assertEquals(4, test.totalSize()); assertEquals(1, test.getCollection("keyA").size()); assertEquals(3, test.getCollection("key").size()); assertEquals(true, test.containsValue("objectA")); assertEquals(true, test.containsValue("object0")); assertEquals(true, test.containsValue("object1")); assertEquals(true, test.containsValue("object2")); }
public void setParameters(Map arg0) { parameterMap.clear(); parameterMap.putAll(arg0); }
/** * Override superclass to ensure that MultiMap instances are * correctly handled. * <p> * If you call this method with a normal map, each entry is * added using <code>put(Object,Object)</code>. * If you call this method with a multi map, each entry is * added using <code>putAll(Object,Collection)</code>. * * @param map the map to copy (either a normal or multi map) */ public void putAll(Map map) { if (map instanceof MultiMap) { for (Iterator it = map.entrySet().iterator(); it.hasNext();) { Map.Entry entry = (Map.Entry) it.next(); Collection coll = (Collection) entry.getValue(); putAll(entry.getKey(), coll); } } else { for (Iterator it = map.entrySet().iterator(); it.hasNext();) { Map.Entry entry = (Map.Entry) it.next(); put(entry.getKey(), entry.getValue()); } } }
/** * Override superclass to ensure that MultiMap instances are * correctly handled. * <p> * If you call this method with a normal map, each entry is * added using <code>put(Object,Object)</code>. * If you call this method with a multi map, each entry is * added using <code>putAll(Object,Collection)</code>. * * @param map the map to copy (either a normal or multi map) */ public void putAll(Map map) { if (map instanceof MultiMap) { for (Iterator it = map.entrySet().iterator(); it.hasNext();) { Map.Entry entry = (Map.Entry) it.next(); Collection coll = (Collection) entry.getValue(); putAll(entry.getKey(), coll); } } else { for (Iterator it = map.entrySet().iterator(); it.hasNext();) { Map.Entry entry = (Map.Entry) it.next(); put(entry.getKey(), entry.getValue()); } } }
/** * Override superclass to ensure that MultiMap instances are * correctly handled. * <p> * If you call this method with a normal map, each entry is * added using <code>put(Object,Object)</code>. * If you call this method with a multi map, each entry is * added using <code>putAll(Object,Collection)</code>. * * @param map the map to copy (either a normal or multi map) */ public void putAll(Map map) { if (map instanceof MultiMap) { for (Iterator it = map.entrySet().iterator(); it.hasNext();) { Map.Entry entry = (Map.Entry) it.next(); Collection coll = (Collection) entry.getValue(); putAll(entry.getKey(), coll); } } else { for (Iterator it = map.entrySet().iterator(); it.hasNext();) { Map.Entry entry = (Map.Entry) it.next(); put(entry.getKey(), entry.getValue()); } } }
/** * Override superclass to ensure that MultiMap instances are * correctly handled. * <p> * If you call this method with a normal map, each entry is * added using <code>put(Object,Object)</code>. * If you call this method with a multi map, each entry is * added using <code>putAll(Object,Collection)</code>. * * @param map the map to copy (either a normal or multi map) */ public void putAll(Map map) { if (map instanceof MultiMap) { for (Iterator it = map.entrySet().iterator(); it.hasNext();) { Map.Entry entry = (Map.Entry) it.next(); Collection coll = (Collection) entry.getValue(); putAll(entry.getKey(), coll); } } else { for (Iterator it = map.entrySet().iterator(); it.hasNext();) { Map.Entry entry = (Map.Entry) it.next(); put(entry.getKey(), entry.getValue()); } } }
/** * Override superclass to ensure that MultiMap instances are * correctly handled. * <p> * If you call this method with a normal map, each entry is * added using <code>put(Object,Object)</code>. * If you call this method with a multi map, each entry is * added using <code>putAll(Object,Collection)</code>. * * @param map the map to copy (either a normal or multi map) */ public void putAll(Map map) { if (map instanceof MultiMap) { for (Iterator it = map.entrySet().iterator(); it.hasNext();) { Map.Entry entry = (Map.Entry) it.next(); Collection coll = (Collection) entry.getValue(); putAll(entry.getKey(), coll); } } else { for (Iterator it = map.entrySet().iterator(); it.hasNext();) { Map.Entry entry = (Map.Entry) it.next(); put(entry.getKey(), entry.getValue()); } } }